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

View File

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

View File

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

View File

@ -320,7 +320,7 @@ public class CQLSessionCache implements Shutdownable {
Cluster cl = builder.build();
// Apply default idempotence, if set
activityDef.getParams().getOptionalBoolean("defaultidempotence").map(
activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
b -> cl.getConfiguration().getQueryOptions().setDefaultIdempotence(b)
);
@ -358,7 +358,7 @@ public class CQLSessionCache implements Shutdownable {
try (BufferedInputStream inputStream = new BufferedInputStream(url.openStream());
FileOutputStream fileOS = new FileOutputStream(tmp)) {
byte data[] = new byte[1024];
byte[] data = new byte[1024];
int byteContent;
while ((byteContent = inputStream.read(data, 0, 1024)) != -1) {
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 Pattern templateToken = Pattern.compile("<<(\\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 name;
private CQLStatementDef deprecatedDef; // deprecated, to be removed
public void setBindings(Map<String, String> bindings) {
this.bindings = 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) {
this.stmt = stmt;
this.name = name;
this.bindings = bindings;
}
public Map<String,String> getBindings() {
@ -64,7 +52,7 @@ public class CQLStatementDefParser {
public String getParsedStatementOrError(Set<String> namedBindings) {
ParseResult result = getParseResult(namedBindings);
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();
}
@ -115,13 +103,14 @@ public class CQLStatementDefParser {
private final Set<String> missingGenerators;
private final Set<String> missingAnchors;
private final String statement;
private Map<String,String> bindings;
private final Map<String,String> bindings;
private final String name;
public ParseResult(String stmt, String name, Map<String,String> bindings, Set<String> missingGenerators, Set<String> missingAnchors) {
this.missingGenerators = missingGenerators;
this.missingAnchors = missingAnchors;
this.statement = stmt;
this.bindings = bindings;
this.name = name;
}

View File

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

View File

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

View File

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

View File

@ -304,7 +304,7 @@ public class CQLSessionCache implements Shutdownable {
Cluster cl = builder.build();
// Apply default idempotence, if set
activityDef.getParams().getOptionalBoolean("defaultidempotence").map(
activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
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 Pattern templateToken = Pattern.compile("<<(\\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 name;
private CQLStatementDef deprecatedDef; // deprecated, to be removed
public void setBindings(Map<String, String> bindings) {
this.bindings = 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) {
this.stmt = stmt;
this.name = name;
this.bindings = bindings;
}
public Map<String,String> getBindings() {
@ -64,7 +52,7 @@ public class CQLStatementDefParser {
public String getParsedStatementOrError(Set<String> namedBindings) {
ParseResult result = getParseResult(namedBindings);
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();
}

View File

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

View File

@ -9,6 +9,7 @@ import java.nio.file.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.stream.Stream;
public class ParserForCqlTest {
@ -37,15 +38,14 @@ public class ParserForCqlTest {
URL url = resources.nextElement();
System.out.println("url=" + url.toExternalForm());
Path path = Paths.get(url.toURI());
Files.walk(path, FileVisitOption.FOLLOW_LINKS)
.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS))
.forEach(subpaths::add);
try (Stream<Path> fileStream = Files.walk(path, FileVisitOption.FOLLOW_LINKS)) {
fileStream.filter(p -> !Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS))
.forEach(subpaths::add);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
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.statements.rsoperators.AssertSingleRowResultSet;
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.Logger;
@ -22,27 +23,26 @@ public class CqlVerifyActivity extends CqlActivity {
@Override
public synchronized void initActivity() {
if (!super.getActivityDef().getParams().contains("verify") &&
!super.getActivityDef().getParams().contains("verify-fields")) {
ParameterMap activityParams = super.getActivityDef().getParams();
if (!activityParams.containsKey("verify") &&
!activityParams.containsKey("verify-fields")) {
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.");
super.getActivityDef().getParams().put("verify", "*");
activityParams.put("verify", "*");
}
if (!super.getActivityDef().getParams().contains("compare")) {
super.getActivityDef().getParams().put("compare", "all");
if (!activityParams.containsKey("compare")) {
activityParams.put("compare", "all");
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.");
}
super.initActivity();
}
@Override
public void onActivityDefUpdate(ActivityDef activityDef) {
super.onActivityDefUpdate(activityDef);
addResultSetCycleOperator(new AssertSingleRowResultSet());
}
}

View File

@ -209,10 +209,10 @@ public class GraphActivity extends SimpleActivity implements ActivityDefObserver
try {
cluster = builder.build();
} 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;
}
activityDef.getParams().getOptionalBoolean("defaultidempotence").map(
activityDef.getParams().getOptionalBoolean("defaultidempotence").ifPresent(
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());
return session;
} 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;
}

View File

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

View File

@ -197,6 +197,6 @@ public class PulsarActivity extends SimpleActivity implements ActivityDefObserve
}
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
Stopped("_\u23F9");
private String runcode;
private final String runcode;
RunState(String runcode) {
this.runcode = runcode;

View File

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

View File

@ -67,9 +67,6 @@ import java.util.function.ToLongFunction;
*/
public class IntervalSequencer<T> implements ElementSequencer<T> {
private List<T> elems;
private ToLongFunction<T> ratioFunc;
@Override
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 T elem;
private double position;
private int rank;
private final T elem;
private final double position;
private final int rank;
public OpSlot(T elem, double position, int rank) {
this.elem = elem;

View File

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

View File

@ -178,8 +178,6 @@ public class RateSpec {
}
public String toString() {
StringBuilder sb = new StringBuilder();
double ratePortion = Math.abs(opsPerSec - ((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() {
if (hasError()) {
throw new RuntimeException("Unable to parse statement: " + this.toString());
throw new RuntimeException("Unable to parse statement: " + this);
}
return this;
}
@ -149,14 +149,6 @@ public class ParsedStmt {
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
*/

View File

@ -27,8 +27,6 @@ import java.util.*;
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 StmtsDoc rawStmtsDoc;
private final int blockIdx;

View File

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

View File

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

View File

@ -41,7 +41,6 @@ public class HistoStatsCSVWriter {
private PrintStream initFile(File logfile) {
try {
FileOutputStream fileOutputStream = new FileOutputStream(logfile);
PrintStream writer = new PrintStream(logfile);
return writer;
} catch (IOException e) {
@ -66,7 +65,7 @@ public class HistoStatsCSVWriter {
Locale.US,
"#[StartTime: %.3f (seconds since epoch), %s]\n",
startTime / 1000.0,
new Date(startTime).toString()
new Date(startTime)
);
writer.flush();
}
@ -104,7 +103,7 @@ public class HistoStatsCSVWriter {
csvLine.append(",").append(h.getValueAtPercentile(0.999D));
csvLine.append(",").append(h.getValueAtPercentile(0.9999D));
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() {
StringBuilder sb = new StringBuilder();
sb.append("HistoLogger:" + this.pattern + ":" + this.logfile.getPath() + ":" + this.intervalLength);
return sb.toString();
return "HistoLogger:" + this.pattern + ":" + this.logfile.getPath() + ":" + this.intervalLength;
}
public long getInterval() {

View File

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

View File

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

View File

@ -44,6 +44,6 @@ public class RateSpecTest {
RateSpec d = new RateSpec("12345,1.4,restart");
assertThat(d.verb).isEqualTo(RateSpec.Verb.restart);
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);
ParsedStmt parsed1 = stmtDef1.getParsed();
assertThat(parsed1.getMissingBindings().isEmpty());
assertThat(parsed1.getMissingBindings()).isEmpty();
assertThat(parsed1.hasError()).isFalse();
}

View File

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

View File

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

View File

@ -177,27 +177,28 @@ public class TestNBCLIOptions {
@Test
public void listWorkloads() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-workloads"});
List<Cmd> cmds = opts.getCommands();
assertThat(opts.wantsScenariosList());
assertThat(opts.wantsWorkloadsList()).isTrue();
}
@Test
public void listScenarios() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scenarios"});
assertThat(opts.wantsScenariosList()).isTrue();
}
@Test
public void listScripts() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scripts"});
List<Cmd> cmds = opts.getCommands();
assertThat(opts.wantsScriptList());
assertThat(opts.wantsScriptList()).isTrue();
}
@Test
public void clTest() {
String dir= "./";
URL resource = getClass().getClassLoader().getResource(dir);
assertThat(resource);
assertThat(resource).isNotNull();
Path basePath = NBIO.getFirstLocalPath(dir);
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() {
logger.info("starting activity " + activity.getAlias() + " for cycles " + activity.getCycleSummary());
this.annotatedCommand = annotatedCommand;
Annotators.recordAnnotation(Annotation.newBuilder()
.session(sessionId)
.now()
@ -248,7 +247,6 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
return wasStopped;
}
/**
* Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of
* changes.
@ -256,9 +254,7 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
@Override
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
// 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
* @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;
long waitstart = System.currentTimeMillis();
long remaining = waitTimeMillis;
List<ActivityFinisher> finishers = new ArrayList<>();
@ -410,7 +409,6 @@ public class ScenarioController {
}
return completed;
}
private ActivityDef aliasToDef(String alias) {

View File

@ -311,7 +311,7 @@ public class Scenario implements Callable<ScenarioResult> {
endedAtMillis = System.currentTimeMillis();
}
}
int awaitCompletionTime = 86400 * 365 * 1000;
long awaitCompletionTime = 86400 * 365 * 1000L;
logger.debug("Awaiting completion of scenario for " + awaitCompletionTime + " millis.");
scenarioController.awaitCompletion(awaitCompletionTime);
//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<>();
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);
}

View File

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

View File

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

View File

@ -56,16 +56,13 @@ public class WorkspaceFinder {
public List<WorkspaceView> getWorkspaceViews() {
List<WorkspaceView> views = new ArrayList<>();
DirectoryStream<Path> wsrEntries = null;
try {
wsrEntries = Files.newDirectoryStream(root);
try (DirectoryStream<Path> wsrEntries = Files.newDirectoryStream(root)) {
for (Path entry : wsrEntries) {
views.add(new WorkspaceView(entry));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
for (Path entry : wsrEntries) {
views.add(new WorkspaceView(entry));
}
return views;
}
@ -137,7 +134,7 @@ public class WorkspaceFinder {
Path relativize = root.relativize(path);
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)) {
@ -145,9 +142,9 @@ public class WorkspaceFinder {
.map(Path::toFile)
// .peek(System.out::println)
.forEach(f -> {
logger.debug("deleting '" + f.toString() + "'");
logger.debug("deleting '" + f + "'");
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() {
List<String> workspaces = new ArrayList<>();
try {
DirectoryStream<Path> paths = Files.newDirectoryStream(workspacesRoot);
try (DirectoryStream<Path> paths = Files.newDirectoryStream(workspacesRoot)) {
for (Path path : paths) {
workspaces.add(path.toString());
}

View File

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

View File

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

View File

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

View File

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

View File

@ -48,8 +48,6 @@ public class FunctionManifestProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
List<Element> ts = new ArrayList<>();
try {
if (writer==null) {
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);
private final Class<?> functionClass;
private Class<?> inputClass;
private Class<?> returnClass;
private ValueType returnValueType;
private ValueType inputValueType;
private final Class<?> inputClass;
private final Class<?> returnClass;
private final ValueType returnValueType;
private final ValueType inputValueType;
FunctionType(Class<?> functionClass, Class<?> inputClass, Class<?> returnClass) {
this.functionClass = functionClass;

View File

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

View File

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

View File

@ -13,10 +13,9 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class ParsedTemplateTest {
private final Map<String, String> bindings = new HashMap<>() {{
put("bindname1", "bindspec1");
put("bindname2", "bindspec2");
}};
private final Map<String, String> bindings = Map.of(
"bindname1", "bindspec1",
"bindname2", "bindspec2");
private final String rawNothing = "This has no anchors";
private final String oneCurly = "A {curly} brace.";
private final String oneQuestion = " A ?question anchor.";
@ -35,7 +34,7 @@ public class ParsedTemplateTest {
public void testShoudlMatchCurlyBraces() {
ParsedTemplate pt = new ParsedTemplate(oneCurly, bindings);
assertThat(pt.getSpans()).containsExactly("A ", "curly", " brace.");
assertThat(pt.getSpecificBindings().isEmpty());
assertThat(pt.getSpecificBindings()).isEmpty();
assertThat(pt.getMissingBindings()).contains("curly");
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.library.basics.core.stathelpers.AliasElementSampler;
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 org.apache.commons.csv.CSVParser;
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')",""})
public CSVSampler(String labelColumn, String weightColumn, String... data) {
List<EvProbD> events = new ArrayList<>();
List<String> values = new ArrayList<>();
Function<LabeledStatistic, Double> weightFunc = LabeledStatistic::sum;
LongUnaryOperator prefunc = new Hash();

View File

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

View File

@ -23,13 +23,11 @@ public class WeightedFuncs implements LongFunction<Object> {
private final LongFunction<Object>[] funcs;
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) {
List<EvProbD> probabilites = new ArrayList<>();
List<LongFunction<Object>> functions = new ArrayList<>();
List<EvProbD> probabilities = new ArrayList<>();
List<LongFunction<Object>> functions = new ArrayList<>();
if ((weightsAndFuncs.length % 2) != 0) {
throw new RuntimeException("You must have weights and functions, pairwise." +
@ -45,7 +43,7 @@ public class WeightedFuncs implements LongFunction<Object> {
} catch (NumberFormatException nfe) {
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];
try {
@ -58,7 +56,7 @@ public class WeightedFuncs implements LongFunction<Object> {
}
}
this.funcs = functions.toArray(new LongFunction[0]);
this.functionSampler = new AliasSamplerDoubleInt(probabilites);
this.functionSampler = new AliasSamplerDoubleInt(probabilities);
}
@Override

View File

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

View File

@ -23,8 +23,6 @@ public class ShowTest {
assertThat(showFoo.apply(2342343L)).isEqualTo("{foo=23}");
assertThat(showBar.apply(23423L)).isEqualTo("{bar=Bar}");
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 {
@Test
public void testGetDataMapper() throws Exception {
Optional<DataMapper<Object>> dataMapper = VirtData.getOptionalMapper("StaticStringMapper('foo')");
@ -52,6 +51,7 @@ public class BasicDataMappersTest {
assertThat(dataMapper.get()).isNotNull();
Date d1 = dataMapper.get().get(1);
Date d2 = dataMapper.get().get(2);
assertThat(d2).isAfter(d1);
}
@Test
@ -59,7 +59,9 @@ public class BasicDataMappersTest {
Optional<DataMapper<Date>> dataMapper = VirtData.getOptionalMapper("ToDate(1000,10000)");
assertThat(dataMapper).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
@ -69,5 +71,4 @@ public class BasicDataMappersTest {
assertThat(dataMapper.get()).isNotNull();
assertThat(dataMapper.get().get(1)).isNotNull();
}
}

View File

@ -22,7 +22,10 @@ public class ToEpochTimeUUIDTest {
formats.add(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
*/
private boolean direction;
private final boolean direction;
/**
* Create a Direction with the given value.

View File

@ -216,7 +216,7 @@ public class IntegratedBindingsTest {
public void testDirectFunctionalInterfaceLongUnary() {
LongUnaryOperator f = VirtData.getFunction("Add(5L)", LongUnaryOperator.class);
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

View File

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