post-merge fixups

This commit is contained in:
Jonathan Shook 2021-06-17 13:02:14 -05:00
commit 7c7ea039da
61 changed files with 130 additions and 235 deletions

View File

@ -180,12 +180,6 @@ public class DocsysMarkdownEndpoint implements WebServiceObject {
} }
private void enable(Set<String> enabled) { private void enable(Set<String> enabled) {
Set<String> toEnable = new HashSet<>();
if (this.enables !=null) {
toEnable.addAll(this.enables);
}
for (DocsNameSpace nsinfo : docsinfo) { for (DocsNameSpace nsinfo : docsinfo) {
// add namespaces which are neither enabled nor disabled to the default group // add namespaces which are neither enabled nor disabled to the default group
if (nsinfo.isEnabledByDefault()) { if (nsinfo.isEnabledByDefault()) {
@ -204,6 +198,4 @@ public class DocsysMarkdownEndpoint implements WebServiceObject {
this.enabled = disabled.remove(enabled); this.enabled = disabled.remove(enabled);
} }
} }
} }

View File

@ -75,13 +75,12 @@ public class DateRangeFunc implements LongFunction<DateRange> {
this.upper = upper; this.upper = upper;
} }
@Override @Override
public DateRange apply(long value) { public DateRange apply(long value) {
Date lowerDate = new Date(lower.applyAsLong(value)); Date lowerDate = new Date(lower.applyAsLong(value));
DateRange.DateRangeBound lower = DateRange.DateRangeBound.lowerBound(lowerDate,precision); DateRange.DateRangeBound lower = DateRange.DateRangeBound.lowerBound(lowerDate,precision);
Date upperDate = new Date(upper.applyAsLong(value)); Date upperDate = new Date(upper.applyAsLong(value));
DateRange.DateRangeBound upper = DateRange.DateRangeBound.upperBound(lowerDate,precision); DateRange.DateRangeBound upper = DateRange.DateRangeBound.upperBound(upperDate,precision);
DateRange dateRange = new DateRange(lower, upper); DateRange dateRange = new DateRange(lower, upper);
return dateRange; return dateRange;
} }

View File

@ -30,8 +30,6 @@ public class AvailableCQLStatements {
} }
public List<CQLStatementDefParser> getMatching(String tagSpec) { public List<CQLStatementDefParser> getMatching(String tagSpec) {
List<CQLStatementDefParser> defs = new ArrayList<>();
TagFilter ts = new TagFilter(tagSpec); TagFilter ts = new TagFilter(tagSpec);
List<CQLStatementDefParser> CQLStatementDefParsers = List<CQLStatementDefParser> CQLStatementDefParsers =
availableDefs.stream() availableDefs.stream()

View File

@ -320,7 +320,7 @@ public class CQLSessionCache implements Shutdownable {
Cluster cl = builder.build(); Cluster cl = builder.build();
// Apply default idempotence, if set // Apply default idempotence, if set
activityDef.getParams().getOptionalBoolean("defaultidempotence").map( activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
b -> cl.getConfiguration().getQueryOptions().setDefaultIdempotence(b) b -> cl.getConfiguration().getQueryOptions().setDefaultIdempotence(b)
); );
@ -358,7 +358,7 @@ public class CQLSessionCache implements Shutdownable {
try (BufferedInputStream inputStream = new BufferedInputStream(url.openStream()); try (BufferedInputStream inputStream = new BufferedInputStream(url.openStream());
FileOutputStream fileOS = new FileOutputStream(tmp)) { FileOutputStream fileOS = new FileOutputStream(tmp)) {
byte data[] = new byte[1024]; byte[] data = new byte[1024];
int byteContent; int byteContent;
while ((byteContent = inputStream.read(data, 0, 1024)) != -1) { while ((byteContent = inputStream.read(data, 0, 1024)) != -1) {
fileOS.write(data, 0, byteContent); fileOS.write(data, 0, byteContent);

View File

@ -12,30 +12,18 @@ public class CQLStatementDefParser {
private final static Logger logger = LogManager.getLogger(CQLStatementDefParser.class); private final static Logger logger = LogManager.getLogger(CQLStatementDefParser.class);
// private final static Pattern templateToken = Pattern.compile("<<(\\w+(:(.+?))?)>>"); // private final static Pattern templateToken = Pattern.compile("<<(\\w+(:(.+?))?)>>");
private final static Pattern stmtToken = Pattern.compile("\\?(\\w+[-_\\d\\w]*)|\\{(\\w+[-_\\d\\w.]*)}"); private final static Pattern stmtToken = Pattern.compile("\\?(\\w+[-_\\d\\w]*)|\\{(\\w+[-_\\d\\w.]*)}");
private final static String UNSET_VALUE = "UNSET-VALUE";
private final String stmt; private final String stmt;
private final String name; private final String name;
private CQLStatementDef deprecatedDef; // deprecated, to be removed
public void setBindings(Map<String, String> bindings) { public void setBindings(Map<String, String> bindings) {
this.bindings = bindings; this.bindings = bindings;
} }
private Map<String, String> bindings; private Map<String, String> bindings;
public CQLStatementDef getDeprecatedDef() {
return deprecatedDef;
}
public void setDeprecatedDef(CQLStatementDef deprecatedDef) {
this.deprecatedDef = deprecatedDef;
}
public CQLStatementDefParser(String name, String stmt) { public CQLStatementDefParser(String name, String stmt) {
this.stmt = stmt; this.stmt = stmt;
this.name = name; this.name = name;
this.bindings = bindings;
} }
public Map<String,String> getBindings() { public Map<String,String> getBindings() {
@ -64,7 +52,7 @@ public class CQLStatementDefParser {
public String getParsedStatementOrError(Set<String> namedBindings) { public String getParsedStatementOrError(Set<String> namedBindings) {
ParseResult result = getParseResult(namedBindings); ParseResult result = getParseResult(namedBindings);
if (result.hasError()) { if (result.hasError()) {
throw new RuntimeException("Statement template has errors:\n" + result.toString()); throw new RuntimeException("Statement template has errors:\n" + result);
} }
return result.getStatement(); return result.getStatement();
} }
@ -115,13 +103,14 @@ public class CQLStatementDefParser {
private final Set<String> missingGenerators; private final Set<String> missingGenerators;
private final Set<String> missingAnchors; private final Set<String> missingAnchors;
private final String statement; private final String statement;
private Map<String,String> bindings; private final Map<String,String> bindings;
private final String name; private final String name;
public ParseResult(String stmt, String name, Map<String,String> bindings, Set<String> missingGenerators, Set<String> missingAnchors) { public ParseResult(String stmt, String name, Map<String,String> bindings, Set<String> missingGenerators, Set<String> missingAnchors) {
this.missingGenerators = missingGenerators; this.missingGenerators = missingGenerators;
this.missingAnchors = missingAnchors; this.missingAnchors = missingAnchors;
this.statement = stmt; this.statement = stmt;
this.bindings = bindings;
this.name = name; this.name = name;
} }

View File

@ -23,7 +23,7 @@ public enum DiffType {
/// the actual data. /// the actual data.
all(0x1|0x1<<1|0x1<<2); all(0x1|0x1<<1|0x1<<2);
public int bitmask; public final int bitmask;
DiffType(int bit) { DiffType(int bit) {
this.bitmask = bit; this.bitmask = bit;

View File

@ -9,6 +9,7 @@ import java.nio.file.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
public class ParserForCqlTest { public class ParserForCqlTest {
@ -37,15 +38,14 @@ public class ParserForCqlTest {
URL url = resources.nextElement(); URL url = resources.nextElement();
System.out.println("url=" + url.toExternalForm()); System.out.println("url=" + url.toExternalForm());
Path path = Paths.get(url.toURI()); Path path = Paths.get(url.toURI());
Files.walk(path, FileVisitOption.FOLLOW_LINKS) try (Stream<Path> fileStream = Files.walk(path, FileVisitOption.FOLLOW_LINKS)) {
.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) fileStream.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS))
.forEach(subpaths::add); .forEach(subpaths::add);
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return subpaths; return subpaths;
} }
} }

View File

@ -30,8 +30,6 @@ public class AvailableCQLStatements {
} }
public List<CQLStatementDefParser> getMatching(String tagSpec) { public List<CQLStatementDefParser> getMatching(String tagSpec) {
List<CQLStatementDefParser> defs = new ArrayList<>();
TagFilter ts = new TagFilter(tagSpec); TagFilter ts = new TagFilter(tagSpec);
List<CQLStatementDefParser> CQLStatementDefParsers = List<CQLStatementDefParser> CQLStatementDefParsers =
availableDefs.stream() availableDefs.stream()

View File

@ -304,7 +304,7 @@ public class CQLSessionCache implements Shutdownable {
Cluster cl = builder.build(); Cluster cl = builder.build();
// Apply default idempotence, if set // Apply default idempotence, if set
activityDef.getParams().getOptionalBoolean("defaultidempotence").map( activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
b -> cl.getConfiguration().getQueryOptions().setDefaultIdempotence(b) b -> cl.getConfiguration().getQueryOptions().setDefaultIdempotence(b)
); );

View File

@ -12,30 +12,18 @@ public class CQLStatementDefParser {
private final static Logger logger = LogManager.getLogger(CQLStatementDefParser.class); private final static Logger logger = LogManager.getLogger(CQLStatementDefParser.class);
// private final static Pattern templateToken = Pattern.compile("<<(\\w+(:(.+?))?)>>"); // private final static Pattern templateToken = Pattern.compile("<<(\\w+(:(.+?))?)>>");
private final static Pattern stmtToken = Pattern.compile("\\?(\\w+[-_\\d\\w]*)|\\{(\\w+[-_\\d\\w.]*)}"); private final static Pattern stmtToken = Pattern.compile("\\?(\\w+[-_\\d\\w]*)|\\{(\\w+[-_\\d\\w.]*)}");
private final static String UNSET_VALUE = "UNSET-VALUE";
private final String stmt; private final String stmt;
private final String name; private final String name;
private CQLStatementDef deprecatedDef; // deprecated, to be removed
public void setBindings(Map<String, String> bindings) { public void setBindings(Map<String, String> bindings) {
this.bindings = bindings; this.bindings = bindings;
} }
private Map<String, String> bindings; private Map<String, String> bindings;
public CQLStatementDef getDeprecatedDef() {
return deprecatedDef;
}
public void setDeprecatedDef(CQLStatementDef deprecatedDef) {
this.deprecatedDef = deprecatedDef;
}
public CQLStatementDefParser(String name, String stmt) { public CQLStatementDefParser(String name, String stmt) {
this.stmt = stmt; this.stmt = stmt;
this.name = name; this.name = name;
this.bindings = bindings;
} }
public Map<String,String> getBindings() { public Map<String,String> getBindings() {
@ -64,7 +52,7 @@ public class CQLStatementDefParser {
public String getParsedStatementOrError(Set<String> namedBindings) { public String getParsedStatementOrError(Set<String> namedBindings) {
ParseResult result = getParseResult(namedBindings); ParseResult result = getParseResult(namedBindings);
if (result.hasError()) { if (result.hasError()) {
throw new RuntimeException("Statement template has errors:\n" + result.toString()); throw new RuntimeException("Statement template has errors:\n" + result);
} }
return result.getStatement(); return result.getStatement();
} }

View File

@ -23,7 +23,7 @@ public enum DiffType {
/// the actual data. /// the actual data.
all(0x1|0x1<<1|0x1<<2); all(0x1|0x1<<1|0x1<<2);
public int bitmask; public final int bitmask;
DiffType(int bit) { DiffType(int bit) {
this.bitmask = bit; this.bitmask = bit;

View File

@ -9,6 +9,7 @@ import java.nio.file.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
public class ParserForCqlTest { public class ParserForCqlTest {
@ -37,15 +38,14 @@ public class ParserForCqlTest {
URL url = resources.nextElement(); URL url = resources.nextElement();
System.out.println("url=" + url.toExternalForm()); System.out.println("url=" + url.toExternalForm());
Path path = Paths.get(url.toURI()); Path path = Paths.get(url.toURI());
Files.walk(path, FileVisitOption.FOLLOW_LINKS) try (Stream<Path> fileStream = Files.walk(path, FileVisitOption.FOLLOW_LINKS)) {
.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) fileStream.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS))
.forEach(subpaths::add); .forEach(subpaths::add);
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return subpaths; return subpaths;
} }
} }

View File

@ -3,6 +3,7 @@ package io.nosqlbench.activitytype.cqlverify;
import io.nosqlbench.activitytype.cql.core.CqlActivity; import io.nosqlbench.activitytype.cql.core.CqlActivity;
import io.nosqlbench.activitytype.cql.statements.rsoperators.AssertSingleRowResultSet; import io.nosqlbench.activitytype.cql.statements.rsoperators.AssertSingleRowResultSet;
import io.nosqlbench.engine.api.activityimpl.ActivityDef; import io.nosqlbench.engine.api.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.activityimpl.ParameterMap;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -22,27 +23,26 @@ public class CqlVerifyActivity extends CqlActivity {
@Override @Override
public synchronized void initActivity() { public synchronized void initActivity() {
if (!super.getActivityDef().getParams().contains("verify") && ParameterMap activityParams = super.getActivityDef().getParams();
!super.getActivityDef().getParams().contains("verify-fields")) { if (!activityParams.containsKey("verify") &&
!activityParams.containsKey("verify-fields")) {
logger.info("Pre-configuring activity param 'verify=*' since none was provided."); logger.info("Pre-configuring activity param 'verify=*' since none was provided.");
logger.info("To control this on a per-statement basis, use the verify param."); logger.info("To control this on a per-statement basis, use the verify param.");
super.getActivityDef().getParams().put("verify", "*"); activityParams.put("verify", "*");
} }
if (!super.getActivityDef().getParams().contains("compare")) { if (!activityParams.containsKey("compare")) {
super.getActivityDef().getParams().put("compare", "all"); activityParams.put("compare", "all");
logger.info("Pre-configuring activity param 'compare=all' since none was provided."); logger.info("Pre-configuring activity param 'compare=all' since none was provided.");
logger.info("To control this on a per-statement basis, use the compare param."); logger.info("To control this on a per-statement basis, use the compare param.");
} }
super.initActivity(); super.initActivity();
} }
@Override @Override
public void onActivityDefUpdate(ActivityDef activityDef) { public void onActivityDefUpdate(ActivityDef activityDef) {
super.onActivityDefUpdate(activityDef); super.onActivityDefUpdate(activityDef);
addResultSetCycleOperator(new AssertSingleRowResultSet()); addResultSetCycleOperator(new AssertSingleRowResultSet());
} }
} }

View File

@ -209,10 +209,10 @@ public class GraphActivity extends SimpleActivity implements ActivityDefObserver
try { try {
cluster = builder.build(); cluster = builder.build();
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while instantiating cluster from builder: " + e.toString(), e); logger.error("Error while instantiating cluster from builder: " + e, e);
throw e; throw e;
} }
activityDef.getParams().getOptionalBoolean("defaultidempotence").map( activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
b -> cluster.getConfiguration().getQueryOptions().setDefaultIdempotence(b) b -> cluster.getConfiguration().getQueryOptions().setDefaultIdempotence(b)
); );
@ -236,7 +236,7 @@ public class GraphActivity extends SimpleActivity implements ActivityDefObserver
logger.info("cluster-metadata-allhosts:\n" + session.getCluster().getMetadata().getAllHosts()); logger.info("cluster-metadata-allhosts:\n" + session.getCluster().getMetadata().getAllHosts());
return session; return session;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while creating a session for dsegraph: " + e.toString(), e); logger.error("Error while creating a session for dsegraph: " + e, e);
throw e; throw e;
} }

View File

@ -108,7 +108,6 @@ public class HttpConsoleFormats {
} }
long mod = 1L; long mod = 1L;
Set<String> incl = new HashSet<>();
long mask = 0L; long mask = 0L;
for (String include : filterSet) { for (String include : filterSet) {

View File

@ -197,6 +197,6 @@ public class PulsarActivity extends SimpleActivity implements ActivityDefObserve
} }
public void asyncOperationFailed(Throwable ex) { public void asyncOperationFailed(Throwable ex) {
this.asyncOperationFailure = asyncOperationFailure; this.asyncOperationFailure = ex;
} }
} }

View File

@ -33,7 +33,7 @@ public enum RunState {
// The thread has stopped. This should only be set by the controlled thread // The thread has stopped. This should only be set by the controlled thread
Stopped("_\u23F9"); Stopped("_\u23F9");
private String runcode; private final String runcode;
RunState(String runcode) { RunState(String runcode) {
this.runcode = runcode; this.runcode = runcode;

View File

@ -83,7 +83,7 @@ public class CycleResultsRLEBufferReadable implements CycleResultSegmentsReadabl
private class ResultSpanIterator implements Iterator<CycleResultsSegment> { private class ResultSpanIterator implements Iterator<CycleResultsSegment> {
private final ByteBuffer iterbuf; private final ByteBuffer iterbuf;
private Predicate<ResultReadable> filter; private final Predicate<ResultReadable> filter;
private CycleResultsSegment next; private CycleResultsSegment next;
public ResultSpanIterator(ByteBuffer buf, Predicate<ResultReadable> filter) { public ResultSpanIterator(ByteBuffer buf, Predicate<ResultReadable> filter) {
@ -104,11 +104,8 @@ public class CycleResultsRLEBufferReadable implements CycleResultSegmentsReadabl
@Override @Override
public CycleResultsSegment next() { public CycleResultsSegment next() {
if (next==null) { if (next == null && !hasNext()) {
hasNext(); throw new RuntimeException("Call to next() but there was no remaining unfiltered data.");
if (next==null) {
throw new RuntimeException("Possible call to next() without calling hasNext(). There was no remaining unfiltered data.");
}
} }
CycleResultsSegment wasNext = this.next; CycleResultsSegment wasNext = this.next;
next=null; next=null;

View File

@ -67,9 +67,6 @@ import java.util.function.ToLongFunction;
*/ */
public class IntervalSequencer<T> implements ElementSequencer<T> { public class IntervalSequencer<T> implements ElementSequencer<T> {
private List<T> elems;
private ToLongFunction<T> ratioFunc;
@Override @Override
public int[] seqIndexByRatioFunc(List<T> elements, ToLongFunction<T> ratioFunc) { public int[] seqIndexByRatioFunc(List<T> elements, ToLongFunction<T> ratioFunc) {
@ -101,9 +98,9 @@ public class IntervalSequencer<T> implements ElementSequencer<T> {
private final static class OpSlot<T> { private final static class OpSlot<T> {
private T elem; private final T elem;
private double position; private final double position;
private int rank; private final int rank;
public OpSlot(T elem, double position, int rank) { public OpSlot(T elem, double position, int rank) {
this.elem = elem; this.elem = elem;

View File

@ -27,7 +27,7 @@ import java.util.function.ToLongFunction;
public class SequencePlanner<T> { public class SequencePlanner<T> {
private final static Logger logger = LogManager.getLogger(SequencePlanner.class); private final static Logger logger = LogManager.getLogger(SequencePlanner.class);
private final SequencerType sequencerType; private final SequencerType sequencerType;
private List<T> elements = new ArrayList<>(); private final List<T> elements = new ArrayList<>();
private final List<Long> ratios = new ArrayList<>(); private final List<Long> ratios = new ArrayList<>();
private int[] elementIndex; private int[] elementIndex;
@ -59,7 +59,6 @@ public class SequencePlanner<T> {
logger.trace("sequencing elements by concatenation"); logger.trace("sequencing elements by concatenation");
this.elementIndex = new ConcatSequencer<T>().seqIndexesByRatios(elements, ratios); this.elementIndex = new ConcatSequencer<T>().seqIndexesByRatios(elements, ratios);
} }
this.elements = elements;
return new Sequence<>(sequencerType, elements, elementIndex); return new Sequence<>(sequencerType, elements, elementIndex);
} }

View File

@ -178,8 +178,6 @@ public class RateSpec {
} }
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder();
double ratePortion = Math.abs(opsPerSec - ((long) opsPerSec)); double ratePortion = Math.abs(opsPerSec - ((long) opsPerSec));
String ratefmt = (ratePortion > 0.001D) ? String.format("%,.3f", opsPerSec) : String.format("%,d", (long) opsPerSec); String ratefmt = (ratePortion > 0.001D) ? String.format("%,.3f", opsPerSec) : String.format("%,d", (long) opsPerSec);

View File

@ -56,7 +56,7 @@ public class ParsedStmt {
public ParsedStmt orError() { public ParsedStmt orError() {
if (hasError()) { if (hasError()) {
throw new RuntimeException("Unable to parse statement: " + this.toString()); throw new RuntimeException("Unable to parse statement: " + this);
} }
return this; return this;
} }
@ -149,14 +149,6 @@ public class ParsedStmt {
return opDef.getBindings(); return opDef.getBindings();
} }
/**
* @return the params from the enclosed {@link OpDef}
* @deprecated You should use {@link #getParamReader()} instead.
*/
public Map<String, Object> getParams() {
return opDef.getParams();
}
/** /**
* @return a params reader from the enclosed {@link OpDef} params map * @return a params reader from the enclosed {@link OpDef} params map
*/ */

View File

@ -27,8 +27,6 @@ import java.util.*;
public class StmtsBlock implements Tagged, Iterable<OpTemplate> { public class StmtsBlock implements Tagged, Iterable<OpTemplate> {
private final static String NameToken = "name";
private final static String StmtToken = "stmt";
private final RawStmtsBlock rawStmtsBlock; private final RawStmtsBlock rawStmtsBlock;
private final StmtsDoc rawStmtsDoc; private final StmtsDoc rawStmtsDoc;
private final int blockIdx; private final int blockIdx;

View File

@ -198,7 +198,7 @@ public class ParameterMap extends ConcurrentHashMap<String,Object> implements Bi
@Override @Override
public void clear() { public void clear() {
logger.debug("parameter map cleared:" + toString()); logger.debug("parameter map cleared:" + this);
super.clear(); super.clear();
markMutation(); markMutation();
@ -206,7 +206,7 @@ public class ParameterMap extends ConcurrentHashMap<String,Object> implements Bi
@Override @Override
public Set<Entry<String, Object>> entrySet() { public Set<Entry<String, Object>> entrySet() {
logger.debug("getting entry set for " + toString()); logger.debug("getting entry set for " + this);
return super.entrySet() return super.entrySet()
.stream() .stream()
.map(e -> new AbstractMap.SimpleEntry<String,Object>(e.getKey(), e.getValue()) {}) .map(e -> new AbstractMap.SimpleEntry<String,Object>(e.getKey(), e.getValue()) {})
@ -377,7 +377,6 @@ public class ParameterMap extends ConcurrentHashMap<String,Object> implements Bi
} }
public static String toJSON(Map<?,?> map) { public static String toJSON(Map<?,?> map) {
StringBuilder sb = new StringBuilder();
List<String> l = new ArrayList<>(); List<String> l = new ArrayList<>();
map.forEach((k,v) -> l.add("'" + k + "': '" + v + "'")); map.forEach((k,v) -> l.add("'" + k + "': '" + v + "'"));
return "params={"+String.join(",\n ",l)+"};\n"; return "params={"+String.join(",\n ",l)+"};\n";

View File

@ -255,7 +255,7 @@ public class SimpleActivity implements Activity, ProgressCapable {
@Override @Override
public void setPhaseLimiter(RateLimiter rateLimiter) { public void setPhaseLimiter(RateLimiter rateLimiter) {
this.phaseLimiter = phaseLimiter; this.phaseLimiter = rateLimiter;
} }
@Override @Override

View File

@ -41,7 +41,6 @@ public class HistoStatsCSVWriter {
private PrintStream initFile(File logfile) { private PrintStream initFile(File logfile) {
try { try {
FileOutputStream fileOutputStream = new FileOutputStream(logfile);
PrintStream writer = new PrintStream(logfile); PrintStream writer = new PrintStream(logfile);
return writer; return writer;
} catch (IOException e) { } catch (IOException e) {
@ -66,7 +65,7 @@ public class HistoStatsCSVWriter {
Locale.US, Locale.US,
"#[StartTime: %.3f (seconds since epoch), %s]\n", "#[StartTime: %.3f (seconds since epoch), %s]\n",
startTime / 1000.0, startTime / 1000.0,
new Date(startTime).toString() new Date(startTime)
); );
writer.flush(); writer.flush();
} }
@ -104,7 +103,7 @@ public class HistoStatsCSVWriter {
csvLine.append(",").append(h.getValueAtPercentile(0.999D)); csvLine.append(",").append(h.getValueAtPercentile(0.999D));
csvLine.append(",").append(h.getValueAtPercentile(0.9999D)); csvLine.append(",").append(h.getValueAtPercentile(0.9999D));
csvLine.append(",").append(h.getMaxValue()); csvLine.append(",").append(h.getMaxValue());
writer.println(csvLine.toString()); writer.println(csvLine);
} }
} }

View File

@ -84,9 +84,7 @@ public class HistoStatsLogger extends CapabilityHook<HdrDeltaHistogramAttachment
} }
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); return "HistoLogger:" + this.pattern + ":" + this.logfile.getPath() + ":" + this.intervalLength;
sb.append("HistoLogger:" + this.pattern + ":" + this.logfile.getPath() + ":" + this.intervalLength);
return sb.toString();
} }
public long getInterval() { public long getInterval() {

View File

@ -26,9 +26,8 @@ import java.util.concurrent.TimeUnit;
public class NicerTimer extends Timer implements DeltaSnapshotter, HdrDeltaHistogramAttachment, TimerAttachment { public class NicerTimer extends Timer implements DeltaSnapshotter, HdrDeltaHistogramAttachment, TimerAttachment {
private final String metricName; private final String metricName;
private DeltaHdrHistogramReservoir deltaHdrHistogramReservoir; private final DeltaHdrHistogramReservoir deltaHdrHistogramReservoir;
private long cacheExpiry = 0L; private long cacheExpiry = 0L;
private ConvenientSnapshot lastSnapshot;
private List<Timer> mirrors; private List<Timer> mirrors;
public NicerTimer(String metricName, DeltaHdrHistogramReservoir deltaHdrHistogramReservoir) { public NicerTimer(String metricName, DeltaHdrHistogramReservoir deltaHdrHistogramReservoir) {

View File

@ -239,13 +239,13 @@ public class Unit {
public static Count valueOfSuffix(String suffix) { public static Count valueOfSuffix(String suffix) {
for (Count count : Count.values()) { for (Count count : Count.values()) {
if (count.toString().toLowerCase().equals(suffix.toLowerCase())) { if (count.toString().equalsIgnoreCase(suffix)) {
return count; return count;
} }
if (count.label.toLowerCase().equals(suffix.toLowerCase())) { if (count.label.equalsIgnoreCase(suffix)) {
return count; return count;
} }
if (count.name.toLowerCase().equals(suffix.toLowerCase())) { if (count.name.equalsIgnoreCase(suffix)) {
return count; return count;
} }
} }
@ -265,17 +265,13 @@ public class Unit {
TB("TB", "terabyte", bytesPerGB * 1000), TB("TB", "terabyte", bytesPerGB * 1000),
PB("PB", "petabyte", bytesPerGB * 1000000), PB("PB", "petabyte", bytesPerGB * 1000000),
EB("EB", "exabyte", bytesPerGB * bytesPerGB), EB("EB", "exabyte", bytesPerGB * bytesPerGB),
ZB("ZB", "zettabyte", bytesPerGB * bytesPerGB * 1000),
YB("YB", "yottabyte", bytesPerGB * bytesPerGB * 1000000),
KIB("KiB", "kibibyte", 1024), KIB("KiB", "kibibyte", 1024),
MIB("MiB", "mebibyte", 1024 * 1024), MIB("MiB", "mebibyte", 1024 * 1024),
GIB("GiB", "gibibyte", BytesPerGiB), GIB("GiB", "gibibyte", BytesPerGiB),
TIB("TiB", "tebibyte", BytesPerGiB * 1024), TIB("TiB", "tebibyte", BytesPerGiB * 1024),
PIB("PIB", "pebibyte", BytesPerGiB * 1024 * 1024), PIB("PIB", "pebibyte", BytesPerGiB * 1024 * 1024),
EIB("EiB", "exbibyte", BytesPerGiB * BytesPerGiB), EIB("EiB", "exbibyte", BytesPerGiB * BytesPerGiB);
ZIB("ZiB", "zebibyte", BytesPerGiB * BytesPerGiB * 1024),
YIB("YiB", "yobibyte", BytesPerGiB * BytesPerGiB * 1024 * 1024);
private final String name; private final String name;
private final long bytes; private final long bytes;
@ -289,16 +285,16 @@ public class Unit {
public static Bytes valueOfSuffix(String unitpart) { public static Bytes valueOfSuffix(String unitpart) {
for (Bytes byteUnit : Bytes.values()) { for (Bytes byteUnit : Bytes.values()) {
if (byteUnit.label.toLowerCase().equals(unitpart.toLowerCase())) { if (byteUnit.label.equalsIgnoreCase(unitpart)) {
return byteUnit; return byteUnit;
} }
if (byteUnit.name.toLowerCase().equals(unitpart.toLowerCase())) { if (byteUnit.name.equalsIgnoreCase(unitpart)) {
return byteUnit; return byteUnit;
} }
if ((byteUnit.name.toLowerCase() + "s").equals(unitpart.toLowerCase())) { if ((byteUnit.name.toLowerCase() + "s").equals(unitpart.toLowerCase())) {
return byteUnit; return byteUnit;
} }
if (byteUnit.toString().toLowerCase().equals(unitpart.toLowerCase())) { if (byteUnit.toString().equalsIgnoreCase(unitpart)) {
return byteUnit; return byteUnit;
} }
} }
@ -334,13 +330,13 @@ public class Unit {
public static Duration valueOfSuffix(String spec) { public static Duration valueOfSuffix(String spec) {
for (Duration duration : Duration.values()) { for (Duration duration : Duration.values()) {
if (duration.label.toLowerCase().equals(spec.toLowerCase())) { if (duration.label.equalsIgnoreCase(spec)) {
return duration; return duration;
} }
if (duration.toString().toLowerCase().equals(spec.toLowerCase())) { if (duration.toString().equalsIgnoreCase(spec)) {
return duration; return duration;
} }
if (duration.name.toLowerCase().equals(spec.toLowerCase())) { if (duration.name.equalsIgnoreCase(spec)) {
return duration; return duration;
} }
} }

View File

@ -44,6 +44,6 @@ public class RateSpecTest {
RateSpec d = new RateSpec("12345,1.4,restart"); RateSpec d = new RateSpec("12345,1.4,restart");
assertThat(d.verb).isEqualTo(RateSpec.Verb.restart); assertThat(d.verb).isEqualTo(RateSpec.Verb.restart);
RateSpec c = new RateSpec("12345,1.1"); RateSpec c = new RateSpec("12345,1.1");
assertThat(c.verb== RateSpec.Verb.start); assertThat(c.verb).isEqualTo(RateSpec.Verb.start);
} }
} }

View File

@ -63,7 +63,7 @@ public class ParsedStmtTest {
OpTemplate stmtDef1 = block2.getOps().get(1); OpTemplate stmtDef1 = block2.getOps().get(1);
ParsedStmt parsed1 = stmtDef1.getParsed(); ParsedStmt parsed1 = stmtDef1.getParsed();
assertThat(parsed1.getMissingBindings().isEmpty()); assertThat(parsed1.getMissingBindings()).isEmpty();
assertThat(parsed1.hasError()).isFalse(); assertThat(parsed1.hasError()).isFalse();
} }

View File

@ -47,20 +47,12 @@ public class HistoIntervalLoggerTest {
hil.onHistogramAdded("histo1",nicerHistogram); hil.onHistogramAdded("histo1",nicerHistogram);
List<Long> moments = new ArrayList<>(100);
moments.add(System.currentTimeMillis()); // 0
nicerHistogram.update(1L); nicerHistogram.update(1L);
moments.add(System.currentTimeMillis()); // 1
delay(1001); delay(1001);
moments.add(System.currentTimeMillis()); // 2
nicerHistogram.update(1000000L); nicerHistogram.update(1000000L);
moments.add(System.currentTimeMillis()); // 3
delay(1001); delay(1001);
moments.add(System.currentTimeMillis()); // 4
nicerHistogram.update(1000L); nicerHistogram.update(1000L);
moments.add(System.currentTimeMillis()); // 5
hil.onHistogramRemoved("histo1"); hil.onHistogramRemoved("histo1");
moments.add(System.currentTimeMillis()); // 6
hil.closeMetrics(); hil.closeMetrics();
@ -73,7 +65,7 @@ public class HistoIntervalLoggerTest {
break; break;
} }
histos.add(histogram); histos.add(histogram);
}; }
assertThat(histos.size()).isEqualTo(2); assertThat(histos.size()).isEqualTo(2);
assertThat(histos.get(0)).isInstanceOf(Histogram.class); assertThat(histos.get(0)).isInstanceOf(Histogram.class);
@ -87,7 +79,7 @@ public class HistoIntervalLoggerTest {
try { try {
Thread.sleep(target-System.currentTimeMillis()); Thread.sleep(target-System.currentTimeMillis());
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} ; }
} }
System.out.println("delayed " + (System.currentTimeMillis() - now) + " millis"); System.out.println("delayed " + (System.currentTimeMillis() - now) + " millis");
} }

View File

@ -45,11 +45,9 @@ public class TagFilterTest {
@Test @Test
public void testSomeFilterTagsNoItemTagsDoesNotMatch() { public void testSomeFilterTagsNoItemTagsDoesNotMatch() {
Map<String, String> itemtags = new HashMap<>() {{ Map<String, String> itemtags = new HashMap<>();
}};
TagFilter tf = new TagFilter("tag=foo"); TagFilter tf = new TagFilter("tag=foo");
assertThat(tf.matches(itemtags).matched()).isFalse(); assertThat(tf.matches(itemtags).matched()).isFalse();
} }
@Test @Test
@ -59,7 +57,6 @@ public class TagFilterTest {
}}; }};
TagFilter tf = new TagFilter(""); TagFilter tf = new TagFilter("");
assertThat(tf.matches(itemtags).matched()).isTrue(); assertThat(tf.matches(itemtags).matched()).isTrue();
} }
@Test @Test
@ -77,7 +74,6 @@ public class TagFilterTest {
assertThat(tf.matches(itemtags2).matched()).isTrue(); assertThat(tf.matches(itemtags2).matched()).isTrue();
} }
@Test @Test
public void testMatchingKeyMismatchingValueDoesNotMatch() { public void testMatchingKeyMismatchingValueDoesNotMatch() {
Map<String, String> itemtags = new HashMap<>() {{ Map<String, String> itemtags = new HashMap<>() {{
@ -169,5 +165,4 @@ public class TagFilterTest {
TagFilter tf2 = new TagFilter("any(car:truck,phase:moon)"); TagFilter tf2 = new TagFilter("any(car:truck,phase:moon)");
assertThat(tf2.matches(itemtags).matched()).isFalse(); assertThat(tf2.matches(itemtags).matched()).isFalse();
} }
} }

View File

@ -177,27 +177,28 @@ public class TestNBCLIOptions {
@Test @Test
public void listWorkloads() { public void listWorkloads() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-workloads"}); NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-workloads"});
List<Cmd> cmds = opts.getCommands(); assertThat(opts.wantsWorkloadsList()).isTrue();
assertThat(opts.wantsScenariosList()); }
@Test
public void listScenarios() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scenarios"});
assertThat(opts.wantsScenariosList()).isTrue();
} }
@Test @Test
public void listScripts() { public void listScripts() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scripts"}); NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scripts"});
List<Cmd> cmds = opts.getCommands(); assertThat(opts.wantsScriptList()).isTrue();
assertThat(opts.wantsScriptList());
} }
@Test @Test
public void clTest() { public void clTest() {
String dir= "./"; String dir= "./";
URL resource = getClass().getClassLoader().getResource(dir); URL resource = getClass().getClassLoader().getResource(dir);
assertThat(resource); assertThat(resource).isNotNull();
Path basePath = NBIO.getFirstLocalPath(dir); Path basePath = NBIO.getFirstLocalPath(dir);
List<Path> yamlPathList = PathWalker.findAll(basePath).stream().filter(f -> f.toString().endsWith(".yaml")).collect(Collectors.toList()); List<Path> yamlPathList = PathWalker.findAll(basePath).stream().filter(f -> f.toString().endsWith(".yaml")).collect(Collectors.toList());
assertThat(yamlPathList); assertThat(yamlPathList).isNotEmpty();
} }
} }

View File

@ -98,7 +98,6 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
*/ */
public synchronized void startActivity() { public synchronized void startActivity() {
logger.info("starting activity " + activity.getAlias() + " for cycles " + activity.getCycleSummary()); logger.info("starting activity " + activity.getAlias() + " for cycles " + activity.getCycleSummary());
this.annotatedCommand = annotatedCommand;
Annotators.recordAnnotation(Annotation.newBuilder() Annotators.recordAnnotation(Annotation.newBuilder()
.session(sessionId) .session(sessionId)
.now() .now()
@ -248,7 +247,6 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
return wasStopped; return wasStopped;
} }
/** /**
* Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of * Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of
* changes. * changes.
@ -256,9 +254,7 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
@Override @Override
public synchronized void handleParameterMapUpdate(ParameterMap parameterMap) { public synchronized void handleParameterMapUpdate(ParameterMap parameterMap) {
if (activity instanceof ActivityDefObserver) { activity.onActivityDefUpdate(activityDef);
activity.onActivityDefUpdate(activityDef);
}
// An activity must be initialized before the motors and other components are // An activity must be initialized before the motors and other components are
// considered ready to handle parameter map changes. This is signaled in an activity // considered ready to handle parameter map changes. This is signaled in an activity

View File

@ -383,9 +383,8 @@ public class ScenarioController {
* @param waitTimeMillis The time to wait, usually set very high * @param waitTimeMillis The time to wait, usually set very high
* @return true, if all activities completed before the timer expired, false otherwise * @return true, if all activities completed before the timer expired, false otherwise
*/ */
public boolean awaitCompletion(int waitTimeMillis) { public boolean awaitCompletion(long waitTimeMillis) {
boolean completed = true; boolean completed = true;
long waitstart = System.currentTimeMillis();
long remaining = waitTimeMillis; long remaining = waitTimeMillis;
List<ActivityFinisher> finishers = new ArrayList<>(); List<ActivityFinisher> finishers = new ArrayList<>();
@ -410,7 +409,6 @@ public class ScenarioController {
} }
return completed; return completed;
} }
private ActivityDef aliasToDef(String alias) { private ActivityDef aliasToDef(String alias) {

View File

@ -311,7 +311,7 @@ public class Scenario implements Callable<ScenarioResult> {
endedAtMillis = System.currentTimeMillis(); endedAtMillis = System.currentTimeMillis();
} }
} }
int awaitCompletionTime = 86400 * 365 * 1000; long awaitCompletionTime = 86400 * 365 * 1000L;
logger.debug("Awaiting completion of scenario for " + awaitCompletionTime + " millis."); logger.debug("Awaiting completion of scenario for " + awaitCompletionTime + " millis.");
scenarioController.awaitCompletion(awaitCompletionTime); scenarioController.awaitCompletion(awaitCompletionTime);
//TODO: Ensure control flow covers controller shutdown in event of internal error. //TODO: Ensure control flow covers controller shutdown in event of internal error.

View File

@ -113,7 +113,7 @@ public class ScenariosExecutor {
} }
Map<Scenario, ScenarioResult> scenarioResultMap = new LinkedHashMap<>(); Map<Scenario, ScenarioResult> scenarioResultMap = new LinkedHashMap<>();
getAsyncResultStatus() getAsyncResultStatus()
.entrySet().forEach(es -> scenarioResultMap.put(es.getKey(), es.getValue().orElseGet(null))); .entrySet().forEach(es -> scenarioResultMap.put(es.getKey(), es.getValue().orElse(null)));
return new ScenariosResults(this, scenarioResultMap); return new ScenariosResults(this, scenarioResultMap);
} }

View File

@ -85,13 +85,11 @@ public class DockerHelper {
portBindings.add(pb); portBindings.add(pb);
} }
List<Volume> volumeList = new ArrayList<>();
List<Bind> volumeBindList = new ArrayList<>(); List<Bind> volumeBindList = new ArrayList<>();
for (String volumeDesc : volumeDescList) { for (String volumeDesc : volumeDescList) {
String volFrom = volumeDesc.split(":")[0]; String volFrom = volumeDesc.split(":")[0];
String volTo = volumeDesc.split(":")[1]; String volTo = volumeDesc.split(":")[1];
Volume vol = new Volume(volTo); Volume vol = new Volume(volTo);
volumeList.add(vol);
volumeBindList.add(new Bind(volFrom, vol)); volumeBindList.add(new Bind(volFrom, vol));
} }
@ -121,7 +119,6 @@ public class DockerHelper {
} }
return containerResponse.getId(); return containerResponse.getId();
} }
private boolean startStoppedContainer(String name) { private boolean startStoppedContainer(String name) {

View File

@ -123,8 +123,7 @@ public class WorkSpace {
List<WorkspaceItemView> items = new ArrayList<>(); List<WorkspaceItemView> items = new ArrayList<>();
try { try (DirectoryStream<Path> elementPaths = Files.newDirectoryStream(target)) {
DirectoryStream<Path> elementPaths = Files.newDirectoryStream(target);
for (Path elementPath : elementPaths) { for (Path elementPath : elementPaths) {
items.add(new WorkspaceItemView(this.workspacePath,elementPath)); items.add(new WorkspaceItemView(this.workspacePath,elementPath));
} }

View File

@ -56,16 +56,13 @@ public class WorkspaceFinder {
public List<WorkspaceView> getWorkspaceViews() { public List<WorkspaceView> getWorkspaceViews() {
List<WorkspaceView> views = new ArrayList<>(); List<WorkspaceView> views = new ArrayList<>();
DirectoryStream<Path> wsrEntries = null; try (DirectoryStream<Path> wsrEntries = Files.newDirectoryStream(root)) {
try { for (Path entry : wsrEntries) {
wsrEntries = Files.newDirectoryStream(root); views.add(new WorkspaceView(entry));
}
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
for (Path entry : wsrEntries) {
views.add(new WorkspaceView(entry));
}
return views; return views;
} }
@ -137,7 +134,7 @@ public class WorkspaceFinder {
Path relativize = root.relativize(path); Path relativize = root.relativize(path);
if (relativize.toString().contains("..")) { if (relativize.toString().contains("..")) {
throw new RuntimeException("Illegal path to delete: " + path.toString()); throw new RuntimeException("Illegal path to delete: " + path);
} }
try (Stream<Path> walk = Files.walk(path)) { try (Stream<Path> walk = Files.walk(path)) {
@ -145,9 +142,9 @@ public class WorkspaceFinder {
.map(Path::toFile) .map(Path::toFile)
// .peek(System.out::println) // .peek(System.out::println)
.forEach(f -> { .forEach(f -> {
logger.debug("deleting '" + f.toString() + "'"); logger.debug("deleting '" + f + "'");
if (!f.delete()) { if (!f.delete()) {
throw new RuntimeException("Unable to delete " + f.toString()); throw new RuntimeException("Unable to delete " + f);
} }
}); });

View File

@ -16,9 +16,7 @@ public class WorkspacesView {
public List<String> getWorkspaces() { public List<String> getWorkspaces() {
List<String> workspaces = new ArrayList<>(); List<String> workspaces = new ArrayList<>();
try (DirectoryStream<Path> paths = Files.newDirectoryStream(workspacesRoot)) {
try {
DirectoryStream<Path> paths = Files.newDirectoryStream(workspacesRoot);
for (Path path : paths) { for (Path path : paths) {
workspaces.add(path.toString()); workspaces.add(path.toString());
} }

View File

@ -32,14 +32,14 @@ public class ServiceProcessor extends AbstractProcessor {
return supportedAnnotations; return supportedAnnotations;
} }
private static Pattern packageNamePattern = Pattern.compile("(?<packageName>.+)?\\.(?<className>.+)"); private static final Pattern packageNamePattern = Pattern.compile("(?<packageName>.+)?\\.(?<className>.+)");
private Filer filer; private Filer filer;
private Map<String, String> options; private Map<String, String> options;
private Elements elementUtils; private Elements elementUtils;
private Messager messenger; private Messager messenger;
private SourceVersion sourceVersion; private SourceVersion sourceVersion;
private Types typeUtils; private Types typeUtils;
private Map<String, Writer> writers = new HashMap<>(); private final Map<String, Writer> writers = new HashMap<>();
@Override @Override
public synchronized void init(ProcessingEnvironment processingEnv) { public synchronized void init(ProcessingEnvironment processingEnv) {
@ -68,8 +68,6 @@ public class ServiceProcessor extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
List<Element> ts = new ArrayList<>();
try { try {
for (String annotationType : this.getSupportedAnnotationTypes()) { for (String annotationType : this.getSupportedAnnotationTypes()) {
Class<? extends Annotation> annotationClass = Class<? extends Annotation> annotationClass =

View File

@ -19,7 +19,6 @@ public class ResolverForURL implements ContentResolver {
@Override @Override
public List<Content<?>> resolve(URI uri) { public List<Content<?>> resolve(URI uri) {
List<Content<?>> contents = new ArrayList<>();
URLContent urlContent = resolveURI(uri); URLContent urlContent = resolveURI(uri);
if (urlContent!=null) { if (urlContent!=null) {
return List.of(urlContent); return List.of(urlContent);

View File

@ -27,13 +27,8 @@ public class MarkdownDocs {
} }
public static List<MarkdownInfo> find(String name, DocScope... scopes) { public static List<MarkdownInfo> find(String name, DocScope... scopes) {
List<MarkdownInfo> aggregated = new ArrayList<>();
List<Content<?>> markdownContent = RawMarkdownSources.getAllMarkdown(); List<Content<?>> markdownContent = RawMarkdownSources.getAllMarkdown();
// Find all topics and aggregators
List<String> aggregators = new ArrayList<>();
List<MarkdownInfo> markdownInfos = markdownContent List<MarkdownInfo> markdownInfos = markdownContent
.stream() .stream()
.map(ParsedMarkdown::new) .map(ParsedMarkdown::new)
@ -78,7 +73,7 @@ public class MarkdownDocs {
return mdgraph.processed(); return mdgraph.processed();
// //
// //
// // List<MarkdownInfo> aggregated = new ArrayList<>();
// List<Edge<List<String>>> edges = new ArrayList<>(); // List<Edge<List<String>>> edges = new ArrayList<>();
// List<String> matchedtopics = null; // List<String> matchedtopics = null;
// //

View File

@ -9,9 +9,9 @@ import java.net.URL;
import java.nio.file.*; import java.nio.file.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.from;
public class MarkdownDocsTest { public class MarkdownDocsTest {
@ -74,16 +74,14 @@ public class MarkdownDocsTest {
URL url = resources.nextElement(); URL url = resources.nextElement();
System.out.println("url="+url.toExternalForm()); System.out.println("url="+url.toExternalForm());
Path path = Paths.get(url.toURI()); Path path = Paths.get(url.toURI());
Files.walk(path, FileVisitOption.FOLLOW_LINKS) try (Stream<Path> fileStream = Files.walk(path, FileVisitOption.FOLLOW_LINKS)) {
.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) fileStream.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS))
.forEach(subpaths::add); .forEach(subpaths::add);
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return subpaths; return subpaths;
} }
} }

View File

@ -48,8 +48,6 @@ public class FunctionManifestProcessor extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
List<Element> ts = new ArrayList<>();
try { try {
if (writer==null) { if (writer==null) {
writer = filer.createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/functions") writer = filer.createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/functions")

View File

@ -24,10 +24,10 @@ public enum FunctionType {
R_T(Function.class, Object.class, Object.class); R_T(Function.class, Object.class, Object.class);
private final Class<?> functionClass; private final Class<?> functionClass;
private Class<?> inputClass; private final Class<?> inputClass;
private Class<?> returnClass; private final Class<?> returnClass;
private ValueType returnValueType; private final ValueType returnValueType;
private ValueType inputValueType; private final ValueType inputValueType;
FunctionType(Class<?> functionClass, Class<?> inputClass, Class<?> returnClass) { FunctionType(Class<?> functionClass, Class<?> inputClass, Class<?> returnClass) {
this.functionClass = functionClass; this.functionClass = functionClass;

View File

@ -29,7 +29,7 @@ public enum ValueType implements Comparator<ValueType> {
OBJECT(Object.class, 8); OBJECT(Object.class, 8);
private final Class<?> clazz; private final Class<?> clazz;
private int precedence; private final int precedence;
ValueType(Class<?> clazz, int precedence) { ValueType(Class<?> clazz, int precedence) {
this.clazz = clazz; this.clazz = clazz;

View File

@ -3,8 +3,8 @@ package io.nosqlbench.virtdata.core.templates;
import java.util.Objects; import java.util.Objects;
public class BindPoint { public class BindPoint {
private String anchor; private final String anchor;
private String bindspec; private final String bindspec;
public BindPoint(String anchor, String bindspec) { public BindPoint(String anchor, String bindspec) {
this.anchor = anchor; this.anchor = anchor;
@ -30,6 +30,11 @@ public class BindPoint {
return Objects.equals(bindspec, bindPoint.bindspec); return Objects.equals(bindspec, bindPoint.bindspec);
} }
@Override
public int hashCode() {
return Objects.hash(anchor, bindspec);
}
@Override @Override
public String toString() { public String toString() {
return "BindPoint{" + return "BindPoint{" +

View File

@ -13,10 +13,9 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class ParsedTemplateTest { public class ParsedTemplateTest {
private final Map<String, String> bindings = new HashMap<>() {{ private final Map<String, String> bindings = Map.of(
put("bindname1", "bindspec1"); "bindname1", "bindspec1",
put("bindname2", "bindspec2"); "bindname2", "bindspec2");
}};
private final String rawNothing = "This has no anchors"; private final String rawNothing = "This has no anchors";
private final String oneCurly = "A {curly} brace."; private final String oneCurly = "A {curly} brace.";
private final String oneQuestion = " A ?question anchor."; private final String oneQuestion = " A ?question anchor.";
@ -35,7 +34,7 @@ public class ParsedTemplateTest {
public void testShoudlMatchCurlyBraces() { public void testShoudlMatchCurlyBraces() {
ParsedTemplate pt = new ParsedTemplate(oneCurly, bindings); ParsedTemplate pt = new ParsedTemplate(oneCurly, bindings);
assertThat(pt.getSpans()).containsExactly("A ", "curly", " brace."); assertThat(pt.getSpans()).containsExactly("A ", "curly", " brace.");
assertThat(pt.getSpecificBindings().isEmpty()); assertThat(pt.getSpecificBindings()).isEmpty();
assertThat(pt.getMissingBindings()).contains("curly"); assertThat(pt.getMissingBindings()).contains("curly");
assertThat(pt.getExtraBindings()).hasSameElementsAs(bindings.keySet()); assertThat(pt.getExtraBindings()).hasSameElementsAs(bindings.keySet());
} }

View File

@ -8,7 +8,6 @@ import io.nosqlbench.virtdata.api.annotations.Example;
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper; import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
import io.nosqlbench.virtdata.library.basics.core.stathelpers.AliasElementSampler; import io.nosqlbench.virtdata.library.basics.core.stathelpers.AliasElementSampler;
import io.nosqlbench.virtdata.library.basics.core.stathelpers.ElemProbD; import io.nosqlbench.virtdata.library.basics.core.stathelpers.ElemProbD;
import io.nosqlbench.virtdata.library.basics.core.stathelpers.EvProbD;
import io.nosqlbench.virtdata.library.basics.shared.from_long.to_long.Hash; import io.nosqlbench.virtdata.library.basics.shared.from_long.to_long.Hash;
import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.CSVRecord;
@ -68,8 +67,6 @@ public class CSVSampler implements LongFunction<String> {
*/ */
@Example({"CSVSampler('USPS','n/a','name','census_state_abbrev')",""}) @Example({"CSVSampler('USPS','n/a','name','census_state_abbrev')",""})
public CSVSampler(String labelColumn, String weightColumn, String... data) { public CSVSampler(String labelColumn, String weightColumn, String... data) {
List<EvProbD> events = new ArrayList<>();
List<String> values = new ArrayList<>();
Function<LabeledStatistic, Double> weightFunc = LabeledStatistic::sum; Function<LabeledStatistic, Double> weightFunc = LabeledStatistic::sum;
LongUnaryOperator prefunc = new Hash(); LongUnaryOperator prefunc = new Hash();

View File

@ -20,8 +20,8 @@ import java.util.function.LongUnaryOperator;
*/ */
public class HostHash implements LongUnaryOperator { public class HostHash implements LongUnaryOperator {
private static long hostHash = computeHostHash(); private static final long hostHash = computeHostHash();
private ByteBuffer bb = ByteBuffer.allocate(Long.BYTES); private final ByteBuffer bb = ByteBuffer.allocate(Long.BYTES);
private Murmur3F murmur3F; private Murmur3F murmur3F;
@Example({"HostHash()","a simple per-host hash function"}) @Example({"HostHash()","a simple per-host hash function"})
@ -60,10 +60,10 @@ public class HostHash implements LongUnaryOperator {
distinctNames.add(iface.getHostName()); distinctNames.add(iface.getHostName());
}); });
List<String> nameList = new ArrayList<>(distinctNames); List<String> nameList = new ArrayList<>(distinctNames);
nameList.sort(String::compareTo); Collections.sort(nameList);
Murmur3F m3f = new Murmur3F(0); Murmur3F m3f = new Murmur3F(0);
m3f.reset(); m3f.reset();
distinctNames.forEach( nameList.forEach(
s -> m3f.update(s.getBytes(StandardCharsets.UTF_8)) s -> m3f.update(s.getBytes(StandardCharsets.UTF_8))
); );
return m3f.getValue(); return m3f.getValue();

View File

@ -23,13 +23,11 @@ public class WeightedFuncs implements LongFunction<Object> {
private final LongFunction<Object>[] funcs; private final LongFunction<Object>[] funcs;
private final AliasSamplerDoubleInt functionSampler; private final AliasSamplerDoubleInt functionSampler;
private HashedDoubleRange unitSampler = new HashedDoubleRange(0.0d, 1.0d); private final HashedDoubleRange unitSampler = new HashedDoubleRange(0.0d, 1.0d);
public WeightedFuncs(Object... weightsAndFuncs) { public WeightedFuncs(Object... weightsAndFuncs) {
List<EvProbD> probabilites = new ArrayList<>();
List<LongFunction<Object>> functions = new ArrayList<>();
List<EvProbD> probabilities = new ArrayList<>(); List<EvProbD> probabilities = new ArrayList<>();
List<LongFunction<Object>> functions = new ArrayList<>();
if ((weightsAndFuncs.length % 2) != 0) { if ((weightsAndFuncs.length % 2) != 0) {
throw new RuntimeException("You must have weights and functions, pairwise." + throw new RuntimeException("You must have weights and functions, pairwise." +
@ -45,7 +43,7 @@ public class WeightedFuncs implements LongFunction<Object> {
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
throw new RuntimeException("the 0th and ever even value must be a floating point weight."); throw new RuntimeException("the 0th and ever even value must be a floating point weight.");
} }
probabilites.add(new EvProbD(i >> 1, weight)); probabilities.add(new EvProbD(i >> 1, weight));
Object f = weightsAndFuncs[i + 1]; Object f = weightsAndFuncs[i + 1];
try { try {
@ -58,7 +56,7 @@ public class WeightedFuncs implements LongFunction<Object> {
} }
} }
this.funcs = functions.toArray(new LongFunction[0]); this.funcs = functions.toArray(new LongFunction[0]);
this.functionSampler = new AliasSamplerDoubleInt(probabilites); this.functionSampler = new AliasSamplerDoubleInt(probabilities);
} }
@Override @Override

View File

@ -143,9 +143,9 @@ public class ShuffleTest {
} }
// return shuffle.stats; // return shuffle.stats;
return new int[0]; return new int[0];
} }
@Test
public void test16() { public void test16() {
int max=16; int max=16;
Shuffle shuffle = new Shuffle(0,max); Shuffle shuffle = new Shuffle(0,max);
@ -161,7 +161,6 @@ public class ShuffleTest {
assertThat(r[i]).isEqualTo(i+1); assertThat(r[i]).isEqualTo(i+1);
} }
// System.out.println("resampling stats for " + max + " values: " + Arrays.toString(shuffle.stats)); // System.out.println("resampling stats for " + max + " values: " + Arrays.toString(shuffle.stats));
} }
@Test @Test

View File

@ -23,8 +23,6 @@ public class ShowTest {
assertThat(showFoo.apply(2342343L)).isEqualTo("{foo=23}"); assertThat(showFoo.apply(2342343L)).isEqualTo("{foo=23}");
assertThat(showBar.apply(23423L)).isEqualTo("{bar=Bar}"); assertThat(showBar.apply(23423L)).isEqualTo("{bar=Bar}");
new Clear().apply(234); new Clear().apply(234);
assertThat(showAll.apply("234").isEmpty()); assertThat(showAll.apply("234")).isEqualTo("{}");
} }
} }

View File

@ -11,7 +11,6 @@ import static org.assertj.core.api.Assertions.assertThat;
public class BasicDataMappersTest { public class BasicDataMappersTest {
@Test @Test
public void testGetDataMapper() throws Exception { public void testGetDataMapper() throws Exception {
Optional<DataMapper<Object>> dataMapper = VirtData.getOptionalMapper("StaticStringMapper('foo')"); Optional<DataMapper<Object>> dataMapper = VirtData.getOptionalMapper("StaticStringMapper('foo')");
@ -52,6 +51,7 @@ public class BasicDataMappersTest {
assertThat(dataMapper.get()).isNotNull(); assertThat(dataMapper.get()).isNotNull();
Date d1 = dataMapper.get().get(1); Date d1 = dataMapper.get().get(1);
Date d2 = dataMapper.get().get(2); Date d2 = dataMapper.get().get(2);
assertThat(d2).isAfter(d1);
} }
@Test @Test
@ -59,7 +59,9 @@ public class BasicDataMappersTest {
Optional<DataMapper<Date>> dataMapper = VirtData.getOptionalMapper("ToDate(1000,10000)"); Optional<DataMapper<Date>> dataMapper = VirtData.getOptionalMapper("ToDate(1000,10000)");
assertThat(dataMapper).isNotNull(); assertThat(dataMapper).isNotNull();
assertThat(dataMapper.get()).isNotNull(); assertThat(dataMapper.get()).isNotNull();
assertThat(dataMapper.get().get(1).after(new Date(1))); assertThat(dataMapper.get().get(0)).isEqualTo(new Date(0));
assertThat(dataMapper.get().get(10)).isEqualTo(new Date(1));
assertThat(dataMapper.get().get(20)).isEqualTo(new Date(2));
} }
@Test @Test
@ -69,5 +71,4 @@ public class BasicDataMappersTest {
assertThat(dataMapper.get()).isNotNull(); assertThat(dataMapper.get()).isNotNull();
assertThat(dataMapper.get().get(1)).isNotNull(); assertThat(dataMapper.get().get(1)).isNotNull();
} }
} }

View File

@ -22,7 +22,10 @@ public class ToEpochTimeUUIDTest {
formats.add(formatted); formats.add(formatted);
e = new ToEpochTimeUUID(formatted); e = new ToEpochTimeUUID(formatted);
}
for (String formatted : formats) {
System.out.println(formatted);
} }
/** /**

View File

@ -340,7 +340,7 @@ public class SemiVariance extends AbstractUnivariateStatistic implements Seriali
/** /**
* boolean value UPSIDE <-> true * boolean value UPSIDE <-> true
*/ */
private boolean direction; private final boolean direction;
/** /**
* Create a Direction with the given value. * Create a Direction with the given value.

View File

@ -216,7 +216,7 @@ public class IntegratedBindingsTest {
public void testDirectFunctionalInterfaceLongUnary() { public void testDirectFunctionalInterfaceLongUnary() {
LongUnaryOperator f = VirtData.getFunction("Add(5L)", LongUnaryOperator.class); LongUnaryOperator f = VirtData.getFunction("Add(5L)", LongUnaryOperator.class);
assertThat(f).isNotNull(); assertThat(f).isNotNull();
assertThat(f.getClass()==LongUnaryOperator.class); assertThat(f.getClass()).isEqualTo(io.nosqlbench.virtdata.library.basics.shared.from_long.to_long.Add.class);
} }
@Test @Test

View File

@ -133,14 +133,13 @@ public class IntegratedComposerLogicTest {
public void sanityCheckFunctionCasting() { public void sanityCheckFunctionCasting() {
Class<?> c1 = NumberNameToString.class; Class<?> c1 = NumberNameToString.class;
Class<?> c2 = LongFunction.class; Class<?> c2 = LongFunction.class;
assertThat(ClassUtils.isAssignable(c1,c2)); assertThat(ClassUtils.isAssignable(c1, c2)).isTrue();
Class<?> c3 = Identity.class; Class<?> c3 = Identity.class;
Class<?> c4 = LongFunction.class; Class<?> c4 = LongFunction.class;
assertThat(ClassUtils.isAssignable(c3,c4)); assertThat(ClassUtils.isAssignable(c3, c4)).isTrue();
LongUnaryOperator f; LongUnaryOperator f;
f = new Identity(); f = new Identity();
} }
@Test @Test