mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
adapters api changes for vector branch and other fixes
This commit is contained in:
parent
acbd1b0524
commit
4fdd39fff9
@ -72,6 +72,11 @@
|
||||
<version>2.13.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig;
|
||||
package io.nosqlbench.adapters.api.activityconfig;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig;
|
||||
package io.nosqlbench.adapters.api.activityconfig;
|
||||
|
||||
import com.amazonaws.util.StringInputStream;
|
||||
import io.nosqlbench.api.content.Content;
|
||||
import io.nosqlbench.api.content.NBIO;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.engine.api.templating.StrInterpolator;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.templating.StrInterpolator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import scala.Option;
|
||||
@ -81,9 +81,7 @@ public class OpsLoader {
|
||||
|
||||
transformer.checkpointAccesses().forEach((k, v) -> {
|
||||
layered.addTemplateVariable(k, v);
|
||||
if (params.containsKey(k)) {
|
||||
params.remove(k);
|
||||
}
|
||||
params.remove(k);
|
||||
});
|
||||
|
||||
return layered;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
|
@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -25,7 +27,13 @@ import java.util.*;
|
||||
* See specification for what this should do in UniformWorkloadSpecificationTest
|
||||
*/
|
||||
public class RawOpDef extends RawOpFields {
|
||||
private final static Logger logger = LogManager.getLogger(RawOpDef.class);
|
||||
|
||||
/**
|
||||
* Contains all the op fields. If the key <em>params</em> is used, then fields are divided
|
||||
* between the op fields map and the params map, with the non-specified one soaking up the dangling
|
||||
* op fields. (Those not under 'op' or 'params' and which are not reserverd words)
|
||||
*/
|
||||
private Object op;
|
||||
|
||||
private final static List<String> opFieldSynonyms = List.of("stmt", "statement", "op", "operation");
|
||||
@ -57,9 +65,19 @@ public class RawOpDef extends RawOpFields {
|
||||
}
|
||||
}
|
||||
if (found.size() == 1) {
|
||||
Object op = map.remove(found.iterator().next());
|
||||
setOp(op);
|
||||
} else if (found.size() > 1) {
|
||||
String keyName = found.iterator().next();
|
||||
Object op = map.remove(keyName);
|
||||
if (op instanceof CharSequence s) {
|
||||
if (!keyName.equals("stmt")) {
|
||||
logger.warn("Used implied stmt field under name '" + keyName + "'. You can just use 'stmt: ... "+ s +"' or the equivalent to avoid this warning.");
|
||||
}
|
||||
map.put("stmt",s.toString());
|
||||
// setOp(new LinkedHashMap<String,Object>(Map.of("stmt",s.toString())));
|
||||
} else {
|
||||
setOp(op);
|
||||
}
|
||||
}
|
||||
if (found.size() > 1) {
|
||||
throw new BasicError("You used " + found + " as an op name, but only one of these is allowed at a time.");
|
||||
} else if ((getName() == null || getName().isEmpty()) && op == null && map.size() > 0) {
|
||||
Map.Entry<String, Object> first = map.entrySet().iterator().next();
|
||||
@ -93,6 +111,8 @@ public class RawOpDef extends RawOpFields {
|
||||
public String getStmt() {
|
||||
if (op instanceof CharSequence) {
|
||||
return op.toString();
|
||||
} else if (op instanceof Map m && m.get("stmt") instanceof CharSequence cs) {
|
||||
return cs.toString();
|
||||
} else {
|
||||
throw new BasicError("tried to access a non-char statement definition with #getStmt()");
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import org.apache.logging.log4j.Logger;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.engine.api.util.AdaptersApiVersionInfo;
|
||||
import io.nosqlbench.adapters.api.util.AdaptersApiVersionInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.content.Content;
|
||||
import io.nosqlbench.api.content.NBIO;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.engine.api.templating.StrInterpolator;
|
||||
import io.nosqlbench.adapters.api.templating.StrInterpolator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.snakeyaml.engine.v2.api.Load;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
|
@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.content.Content;
|
||||
import io.nosqlbench.api.content.NBIO;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.engine.api.templating.StrInterpolator;
|
||||
import io.nosqlbench.adapters.api.templating.StrInterpolator;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.snakeyaml.engine.v2.api.Load;
|
||||
import org.snakeyaml.engine.v2.api.LoadSettings;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.LinkedHashMap;
|
@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.MultiMapLookup;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpDef;
|
||||
import io.nosqlbench.adapters.api.activityconfig.MultiMapLookup;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpDef;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
import io.nosqlbench.api.config.params.Element;
|
||||
import io.nosqlbench.api.config.params.NBParams;
|
||||
@ -35,7 +36,7 @@ import java.util.function.Function;
|
||||
* <p>
|
||||
* The OpTemplate is a structurally normalized type which presents the user-provided op template to the NoSQLBench
|
||||
* loading and templating mechanisms. This type is not generally used directly for new driver development. It is the
|
||||
* backing data which is used by {@link io.nosqlbench.engine.api.templating.ParsedOp}, which is used in drivers to map
|
||||
* backing data which is used by {@link ParsedOp}, which is used in drivers to map
|
||||
* op templates to function to be used for a given cycle value.
|
||||
* </p>
|
||||
*
|
||||
@ -86,8 +87,8 @@ public abstract class OpTemplate implements Tagged {
|
||||
if (type.isAssignableFrom(object.getClass())) {
|
||||
map.put(pname, type.cast(object));
|
||||
} else {
|
||||
throw new RuntimeException("With param named '" + pname + "" +
|
||||
"' You can't assign an object of type '" + object.getClass().getSimpleName() + "" +
|
||||
throw new RuntimeException("With param named '" + pname +
|
||||
"' You can't assign an object of type '" + object.getClass().getSimpleName() +
|
||||
"' to '" + type.getSimpleName() + "'. Maybe the YAML format is suggesting the wrong type.");
|
||||
}
|
||||
}
|
@ -14,14 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* The formats which are recognized as source data for the workload. Any serialization may be supported
|
||||
* which can be converted from a character string to an {@link io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsDocList} structure.
|
||||
* which can be converted from a character string to an {@link RawOpsDocList} structure.
|
||||
*
|
||||
* Those which are derived from paths may be determined by their filename extension. Others, which are provided from internal
|
||||
* NoSQLBench sources, may only be invoked explicitly.
|
@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.MultiMapLookup;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpDef;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsBlock;
|
||||
import io.nosqlbench.adapters.api.activityconfig.MultiMapLookup;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpDef;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsBlock;
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsBlock;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsDoc;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsBlock;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDoc;
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
|
||||
import java.util.ArrayList;
|
@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsDoc;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
import io.nosqlbench.engine.api.util.TagFilter;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDoc;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
import io.nosqlbench.adapters.api.util.TagFilter;
|
||||
import io.nosqlbench.api.config.standard.ConfigModel;
|
||||
import io.nosqlbench.api.config.standard.NBConfigModel;
|
||||
import io.nosqlbench.api.config.standard.NBConfigModelExpander;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawScenarios;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawScenarios;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.activityimpl;
|
||||
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Timer;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.evalcontext.CycleFunction;
|
||||
import io.nosqlbench.adapters.api.evalcontext.CycleFunctions;
|
||||
import io.nosqlbench.adapters.api.evalcontext.GroovyBooleanCycleFunction;
|
||||
import io.nosqlbench.adapters.api.evalcontext.GroovyObjectEqualityFunction;
|
||||
import io.nosqlbench.adapters.api.metrics.ThreadLocalNamedTimers;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.api.config.NBLabels;
|
||||
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* See {@link OpDispenser} for details on how to use this type.
|
||||
* <p>
|
||||
* Some details are tracked per op template, which aligns to the life-cycle of the op dispenser.
|
||||
* Thus, each op dispenser is where the stats for all related operations are kept.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of operation
|
||||
*/
|
||||
public abstract class BaseOpDispenser<T extends Op, S> implements OpDispenser<T>, NBLabeledElement {
|
||||
private final static Logger logger = LogManager.getLogger(BaseOpDispenser.class);
|
||||
public static final String VERIFIER = "verifier";
|
||||
public static final String EXPECTED_RESULT = "expected-result";
|
||||
public static final String VERIFIER_IMPORTS = "verifier-imports";
|
||||
public static final String START_TIMERS = "start-timers";
|
||||
public static final String STOP_TIMERS = "stop-timers";
|
||||
|
||||
private final String opName;
|
||||
protected final DriverAdapter<T, S> adapter;
|
||||
private final NBLabels labels;
|
||||
private boolean instrument;
|
||||
private Histogram resultSizeHistogram;
|
||||
private Timer successTimer;
|
||||
private Timer errorTimer;
|
||||
private final String[] timerStarts;
|
||||
private final String[] timerStops;
|
||||
|
||||
/**
|
||||
* package imports used with "verifiers" or "expected-result" are accumulated here
|
||||
*/
|
||||
private final List verifierImports = new ArrayList();
|
||||
/**
|
||||
* optional invokable functions which throw exceptions when results are not verifiable.
|
||||
* This variable is kept here for diagnostics and debugging. The actual instance used within
|
||||
* each thread is provided by a {@link ThreadLocal} via {@link #getVerifier()}
|
||||
*/
|
||||
private final CycleFunction<Boolean> _verifier;
|
||||
private final ThreadLocal<CycleFunction<Boolean>> tlVerifier;
|
||||
|
||||
protected BaseOpDispenser(final DriverAdapter<T, S> adapter, final ParsedOp op) {
|
||||
opName = op.getName();
|
||||
this.adapter = adapter;
|
||||
labels = op.getLabels();
|
||||
|
||||
this.timerStarts = op.takeOptionalStaticValue(START_TIMERS, String.class)
|
||||
.map(s -> s.split(", *"))
|
||||
.orElse(null);
|
||||
|
||||
this.timerStops = op.takeOptionalStaticValue(STOP_TIMERS, String.class)
|
||||
.map(s -> s.split(", *"))
|
||||
.orElse(null);
|
||||
|
||||
if (null != timerStarts)
|
||||
for (final String timerStart : this.timerStarts) ThreadLocalNamedTimers.addTimer(op, timerStart);
|
||||
|
||||
this.configureInstrumentation(op);
|
||||
this.configureVerifierImports(op);
|
||||
List<CycleFunction<Boolean>> verifiers = new ArrayList<>();
|
||||
verifiers.addAll(configureEqualityVerifier(op));
|
||||
verifiers.addAll(configureAssertionVerifiers(op));
|
||||
this._verifier = CycleFunctions.of((a, b) -> a && b, verifiers, true);
|
||||
this.tlVerifier = ThreadLocal.withInitial(() -> _verifier.newInstance());
|
||||
}
|
||||
|
||||
private CycleFunction<Boolean> cloneVerifiers() {
|
||||
return this._verifier.newInstance();
|
||||
}
|
||||
|
||||
public CycleFunction<Boolean> getVerifier() {
|
||||
return this.tlVerifier.get();
|
||||
}
|
||||
|
||||
private void configureVerifierImports(ParsedOp op) {
|
||||
List imports = op.takeOptionalStaticValue(VERIFIER_IMPORTS, List.class)
|
||||
.orElse(List.of());
|
||||
for (Object element : imports) {
|
||||
if (element instanceof CharSequence cs) {
|
||||
this.verifierImports.add(cs.toString());
|
||||
} else {
|
||||
throw new RuntimeException("Imports must be a character sequence.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<? extends CycleFunction<Boolean>> configureAssertionVerifiers(ParsedOp op) {
|
||||
Map<String, ParsedTemplateString> namedVerifiers = op.getTemplateMap().takeAsNamedTemplates(VERIFIER);
|
||||
List<CycleFunction<Boolean>> verifierFunctions = new ArrayList<>();
|
||||
try {
|
||||
namedVerifiers.forEach((verifierName,stringTemplate) -> {
|
||||
GroovyBooleanCycleFunction verifier =
|
||||
new GroovyBooleanCycleFunction(verifierName, stringTemplate, verifierImports);
|
||||
logger.info("configured verifier:" + verifier);
|
||||
verifierFunctions.add(verifier);
|
||||
});
|
||||
return verifierFunctions;
|
||||
} catch (Exception gre) {
|
||||
throw new OpConfigError("error in verifier:" + gre.getMessage(), gre);
|
||||
}
|
||||
}
|
||||
|
||||
private List<? extends CycleFunction<Boolean>> configureEqualityVerifier(ParsedOp op) {
|
||||
try {
|
||||
return op.takeAsOptionalStringTemplate(EXPECTED_RESULT)
|
||||
.map(tpl -> new GroovyObjectEqualityFunction(op.getName()+"-"+EXPECTED_RESULT, tpl, verifierImports))
|
||||
.map(vl -> {
|
||||
logger.info("Configured equality verifier: " + vl);
|
||||
return vl;
|
||||
})
|
||||
.map(v -> List.of(v))
|
||||
.orElse(List.of());
|
||||
} catch (Exception gre) {
|
||||
throw new OpConfigError("error in verifier:" + gre.getMessage(), gre);
|
||||
}
|
||||
}
|
||||
|
||||
String getOpName() {
|
||||
return this.opName;
|
||||
}
|
||||
|
||||
public DriverAdapter<T, S> getAdapter() {
|
||||
return this.adapter;
|
||||
}
|
||||
|
||||
private void configureInstrumentation(final ParsedOp pop) {
|
||||
instrument = pop.takeStaticConfigOr("instrument", false);
|
||||
if (this.instrument) {
|
||||
final int hdrDigits = pop.getStaticConfigOr("hdr_digits", 4).intValue();
|
||||
successTimer = ActivityMetrics.timer(pop, "success", hdrDigits);
|
||||
errorTimer = ActivityMetrics.timer(pop, "error", hdrDigits);
|
||||
resultSizeHistogram = ActivityMetrics.histogram(pop, "resultset-size", hdrDigits);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(final long cycleValue) {
|
||||
if (null != timerStarts) ThreadLocalNamedTimers.TL_INSTANCE.get().start(this.timerStarts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(final long cycleValue, final long nanoTime, final long resultSize) {
|
||||
if (this.instrument) {
|
||||
this.successTimer.update(nanoTime, TimeUnit.NANOSECONDS);
|
||||
if (-1 < resultSize) this.resultSizeHistogram.update(resultSize);
|
||||
}
|
||||
if (null != timerStops) ThreadLocalNamedTimers.TL_INSTANCE.get().stop(this.timerStops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final long cycleValue, final long resultNanos, final Throwable t) {
|
||||
|
||||
if (this.instrument) this.errorTimer.update(resultNanos, TimeUnit.NANOSECONDS);
|
||||
if (null != timerStops) ThreadLocalNamedTimers.TL_INSTANCE.get().stop(this.timerStops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBLabels getLabels() {
|
||||
return this.labels;
|
||||
}
|
||||
|
||||
}
|
@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
package io.nosqlbench.adapters.api.activityimpl;
|
||||
|
||||
import io.nosqlbench.adapters.api.evalcontext.CycleFunction;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
@ -82,6 +83,7 @@ public interface OpDispenser<T> extends LongFunction<T>, OpResultTracker {
|
||||
*/
|
||||
|
||||
T apply(long value);
|
||||
Serializable getExpectedResultExpression();
|
||||
|
||||
CycleFunction<Boolean> getVerifier();
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
package io.nosqlbench.adapters.api.activityimpl;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -68,7 +69,7 @@ import java.util.function.Function;
|
||||
* The logic which is implemented in the OpMapper must follow closely with the op construction
|
||||
* rules provided to the user. Conversely, the driver maintainer should take care to provide
|
||||
* rules of construction and examples in the documentation.
|
||||
* Each {@link io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter} has a unique
|
||||
* Each {@link DriverAdapter} has a unique
|
||||
* name. The documentation
|
||||
* for each of these should be kept in the bundled resources in a top-level markdown file that
|
||||
* matches the driver name.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
package io.nosqlbench.adapters.api.activityimpl;
|
||||
|
||||
public interface OpResultTracker {
|
||||
void onStart(long cycleValue);
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
package io.nosqlbench.adapters.api.activityimpl;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.docs;
|
||||
package io.nosqlbench.adapters.api.activityimpl.docs;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.api.docsapi.BundledMarkdownManifest;
|
||||
import io.nosqlbench.api.docsapi.Docs;
|
||||
import io.nosqlbench.api.docsapi.DocsBinder;
|
||||
import io.nosqlbench.api.spi.SimpleServiceLoader;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.api.config.standard.*;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.fieldmappers.FieldDestructuringMapper;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.fieldmappers.FieldDestructuringMapper;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.api.docsapi.Docs;
|
||||
import io.nosqlbench.api.docsapi.DocsBinder;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
||||
@ -107,7 +107,7 @@ public interface DriverAdapter<OPTYPE extends Op, SPACETYPE> {
|
||||
* the fields in the op template before they are interpreted canonically.
|
||||
* At this level, the transform is applied once to the input map
|
||||
* (once per op template) to yield the map that is provided to
|
||||
* {@link io.nosqlbench.engine.api.activityimpl.OpMapper} implementations.
|
||||
* {@link OpMapper} implementations.
|
||||
*
|
||||
* @return A function to pre-process the op template fields.
|
||||
*/
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
@ -14,25 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.api.errors;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import java.io.Serializable;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
|
||||
public class ExpectedResultVerificationError extends RuntimeException {
|
||||
private final int triesLeft;
|
||||
private final Serializable expectedResultExpression;
|
||||
public class DryRunOp implements RunnableOp {
|
||||
|
||||
public ExpectedResultVerificationError(int triesLeft, Serializable expectedResultExpression) {
|
||||
this.triesLeft = triesLeft;
|
||||
this.expectedResultExpression = expectedResultExpression;
|
||||
private final Op op;
|
||||
|
||||
public DryRunOp(Op op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
public int getTriesLeft() {
|
||||
return triesLeft;
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
|
||||
public Serializable getExpectedResultExpression() {
|
||||
return expectedResultExpression;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class DryRunOpDispenserWrapper extends BaseOpDispenser<Op, Object> {
|
||||
|
||||
private final OpDispenser<? extends Op> realDispenser;
|
||||
|
||||
public DryRunOpDispenserWrapper(DriverAdapter<Op,Object> adapter, ParsedOp pop, OpDispenser<? extends Op> realDispenser) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
@Override
|
||||
public DryRunOp apply(long cycle) {
|
||||
Op op = realDispenser.apply(cycle);
|
||||
return new DryRunOp(op);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
/**
|
||||
* A result processor can consume data from a result which is contains of a set of
|
@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.decorators;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.decorators;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.engine.api.templating.DriverAdapterDecorators;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.templating.DriverAdapterDecorators;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.fieldmappers;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.fieldmappers;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
@ -34,8 +37,8 @@ import java.util.function.LongFunction;
|
||||
* <p>
|
||||
* If you are using the value in this call to select a specific type of behavior, it is very
|
||||
* likely a candidate for factoring into separate op implementations.
|
||||
* The {@link io.nosqlbench.engine.api.activityimpl.OpMapper}
|
||||
* and {@link io.nosqlbench.engine.api.activityimpl.OpDispenser} abstractions are meant to move
|
||||
* The {@link OpMapper}
|
||||
* and {@link OpDispenser} abstractions are meant to move
|
||||
* op type selection and scheduling to earlier in the activity.
|
||||
* </p>
|
||||
*
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
/**
|
||||
* <p>This is the root type of any operation which is used in a NoSQLBench
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
/**
|
||||
* <p>If an Op implements OpGenerator, then it will be asked for chained
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
/**
|
||||
* Provide the result size for an operation.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
/**
|
||||
* <H2>RunnableOp</H2>
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.BinaryOperator;
|
||||
|
||||
public class CompoundCycleFunction<T> implements CycleFunction<T> {
|
||||
|
||||
private final List<CycleFunction<T>> functions = new ArrayList<>();
|
||||
private final BinaryOperator<T> reducer;
|
||||
|
||||
public CompoundCycleFunction(BinaryOperator<T> reducer, CycleFunction<T> ... functions) {
|
||||
this(reducer, Arrays.asList(functions));
|
||||
|
||||
}
|
||||
public CompoundCycleFunction(BinaryOperator<T> reducer, List<CycleFunction<T>> functions) {
|
||||
this.functions.addAll(functions);
|
||||
this.reducer = reducer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(long value) {
|
||||
return functions.stream()
|
||||
.map(f -> f.apply(value))
|
||||
.reduce(reducer)
|
||||
.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CycleFunction<T> newInstance() {
|
||||
ArrayList<CycleFunction<T>> newFunctionList = new ArrayList<>(this.functions.size());
|
||||
for (CycleFunction<T> function : this.functions) {
|
||||
newFunctionList.add(function.newInstance());
|
||||
}
|
||||
return new CompoundCycleFunction<T>(reducer, newFunctionList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionDetails() {
|
||||
return String.join(
|
||||
", ",
|
||||
functions.stream().map(f -> f.getExpressionDetails()).toList()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> void setVariable(String name, V value) {
|
||||
for (CycleFunction<T> function : functions) {
|
||||
function.setVariable(name, value);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public interface CycleFunction<T> extends LongFunction<T>, VariableInjectable, ExpressionDetails {
|
||||
|
||||
/**
|
||||
* Produce a result from a cycle. This is an encapsulating type for any implementations which need
|
||||
* to
|
||||
* @param value the function argument
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
T apply(long value);
|
||||
|
||||
/**
|
||||
* Get a new instance of a CycleFunction, based on the current one, but with its own instance of any
|
||||
* non-threadsafe elements.
|
||||
* @return A new CycleFunction
|
||||
*/
|
||||
CycleFunction<T> newInstance();
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BinaryOperator;
|
||||
|
||||
public class CycleFunctions {
|
||||
public static <T> CycleFunction<T> of(BinaryOperator<T> reducer, List<CycleFunction<T>> verifiers, T defaultResult) {
|
||||
if (verifiers.size()==0) {
|
||||
return new NOOPVerifier<>(defaultResult);
|
||||
} else if (verifiers.size()==1) {
|
||||
return verifiers.get(0);
|
||||
} else {
|
||||
return new CompoundCycleFunction<>(reducer, verifiers);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NOOPVerifier<V> implements CycleFunction<V> {
|
||||
private final V defaultResult;
|
||||
|
||||
public NOOPVerifier(V defaultResult) {
|
||||
this.defaultResult = defaultResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V apply(long value) {
|
||||
return defaultResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CycleFunction<V> newInstance() {
|
||||
return new NOOPVerifier<>(defaultResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionDetails() {
|
||||
return "return "+ defaultResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> void setVariable(String name, V value) {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityapi.core.ops.fluent;
|
||||
|
||||
public interface FluentOp {
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
public interface ExpressionDetails {
|
||||
String getExpressionDetails();
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroovyBooleanCycleFunction extends GroovyCycleFunction<Boolean> {
|
||||
|
||||
public GroovyBooleanCycleFunction(String name, ParsedTemplateString template, List<String> imports) {
|
||||
super(name, template, imports);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(long value) {
|
||||
return super.apply(value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import groovy.lang.Binding;
|
||||
import groovy.lang.GroovyShell;
|
||||
import groovy.lang.Script;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.virtdata.core.bindings.Bindings;
|
||||
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.BindPoint;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GroovyCycleFunction<T> implements CycleFunction<T> {
|
||||
private final static Logger logger = LogManager.getLogger(GroovyBooleanCycleFunction.class);
|
||||
private final String name;
|
||||
private final List<String> imports;
|
||||
|
||||
protected String scriptText; // Groovy script as provided
|
||||
protected final Script script; // Groovy Script as compiled
|
||||
protected final Binding variableBindings; // Groovy binding layer
|
||||
protected final Bindings bindingFunctions; // NB bindings
|
||||
|
||||
/**
|
||||
* Instantiate a cycle function from basic types
|
||||
* @param scriptText The raw script text, not including any bind point or capture point syntax
|
||||
* @param bindingSpecs The names and recipes of bindings which are referenced in the scriptText
|
||||
* @param imports The package imports to be installed into the execution environment
|
||||
*/
|
||||
public GroovyCycleFunction(String name, String scriptText, Map<String,String> bindingSpecs, List<String> imports) {
|
||||
this.name = name;
|
||||
this.scriptText =scriptText;
|
||||
this.imports = imports;
|
||||
|
||||
// scripting env variable bindings
|
||||
this.variableBindings = new Binding();
|
||||
|
||||
// virtdata bindings to be evaluated at cycle time
|
||||
this.bindingFunctions = new BindingsTemplate().addFieldBindings(bindingSpecs).resolveBindings();
|
||||
|
||||
this.script = compileScript(this.scriptText, imports);
|
||||
}
|
||||
|
||||
public GroovyCycleFunction(String name, ParsedTemplateString template, List<String> imports) {
|
||||
this(
|
||||
name,
|
||||
template.getPositionalStatement(),
|
||||
resolveBindings(template.getBindPoints()),
|
||||
imports
|
||||
);
|
||||
}
|
||||
|
||||
private Script compileScript(String scriptText, List<String> imports) {
|
||||
// add classes which are in the imports to the groovy evaluation context
|
||||
String[] verifiedClasses = expandClassNames(imports);
|
||||
|
||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||
ImportCustomizer importer = new ImportCustomizer().addImports(verifiedClasses);
|
||||
compilerConfiguration.addCompilationCustomizers(importer);
|
||||
|
||||
GroovyShell gshell = new GroovyShell(new Binding(), compilerConfiguration);
|
||||
return gshell.parse(scriptText);
|
||||
}
|
||||
|
||||
private static Map<String, String> resolveBindings(List<BindPoint> bindPoints) {
|
||||
return new BindingsTemplate(bindPoints).getMap();
|
||||
}
|
||||
|
||||
|
||||
protected String[] expandClassNames(List<String> groovyImportedClasses) {
|
||||
ClassLoader loader = BaseOpDispenser.class.getClassLoader();
|
||||
|
||||
List<String> classNames = new ArrayList<>();
|
||||
for (String candidateName : groovyImportedClasses) {
|
||||
if (candidateName.endsWith(".*")) {
|
||||
throw new RuntimeException("You can not use wildcard package imports like '" + candidateName + "'");
|
||||
}
|
||||
try {
|
||||
loader.loadClass(candidateName);
|
||||
classNames.add(candidateName);
|
||||
logger.debug(() -> "added import " + candidateName);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Class '" + candidateName + "' was not found for groovy imports.");
|
||||
}
|
||||
}
|
||||
return classNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionDetails() {
|
||||
return this.scriptText;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <V> void setVariable(String name, V value) {
|
||||
this.variableBindings.setVariable(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(long value) {
|
||||
Map<String, Object> values = bindingFunctions.getAllMap(value);
|
||||
values.forEach((k,v)-> variableBindings.setVariable(k,v));
|
||||
T result= (T) script.run();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CycleFunction<T> newInstance() {
|
||||
return new GroovyCycleFunction<T>(name, scriptText, bindingFunctions,imports);
|
||||
}
|
||||
|
||||
private GroovyCycleFunction(String name, String scriptText, Bindings bindingFunctions, List<String> imports) {
|
||||
this.name = name;
|
||||
this.scriptText = scriptText;
|
||||
this.bindingFunctions = bindingFunctions;
|
||||
this.imports = imports;
|
||||
|
||||
this.script = compileScript(scriptText,imports);
|
||||
this.variableBindings=script.getBinding();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This evaluator uses {@link Object#equals(Object)} to compare the results of an operation with
|
||||
* a constructed value. The script used is meant to only construct the object to compare with.
|
||||
* All context variables can be injected into the script context except for one, the <em>result</em>
|
||||
* variable. This is intercepted and then used as a basis for comparison to the result of executing the
|
||||
* script.
|
||||
*/
|
||||
public class GroovyObjectEqualityFunction extends GroovyCycleFunction<Boolean> {
|
||||
|
||||
private Object result;
|
||||
|
||||
public GroovyObjectEqualityFunction(String name, ParsedTemplateString template, List<String> imports) {
|
||||
super(name, template, imports);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(long value) {
|
||||
Map<String, Object> values = bindingFunctions.getAllMap(value);
|
||||
values.forEach((k,v)-> variableBindings.setVariable(k,v));
|
||||
Object scriptResult= script.run();
|
||||
return scriptResult.equals(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercept and reserve the value of the result injected variable for comparison to the evaluated script result later.
|
||||
*/
|
||||
public void setVariable(String name, Object value) {
|
||||
if (name.equals("result")) {
|
||||
this.result = value;
|
||||
return;
|
||||
}
|
||||
|
||||
super.setVariable(name, value);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ResultMismatchError extends RuntimeException {
|
||||
private final int triesLeft;
|
||||
private final String expressionDetails;
|
||||
|
||||
public ResultMismatchError(String message, int triesLeft, String expressionDetails) {
|
||||
super("Error while verifying result with " + triesLeft + " tries remaining: " + message);
|
||||
this.triesLeft = triesLeft;
|
||||
this.expressionDetails = expressionDetails;
|
||||
}
|
||||
|
||||
public ResultMismatchError(Throwable throwable, int triesLeft, String expressionDetails) {
|
||||
super("Error while verifying result with " + triesLeft + " tries remaining: " + throwable.getMessage(),throwable);
|
||||
this.triesLeft = triesLeft;
|
||||
this.expressionDetails = expressionDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
public int getTriesLeft() {
|
||||
return triesLeft;
|
||||
}
|
||||
|
||||
public Serializable getExpressionDetails() {
|
||||
return expressionDetails;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ResultVerificationError extends RuntimeException {
|
||||
private final int triesLeft;
|
||||
private final String expressionDetails;
|
||||
|
||||
public ResultVerificationError(String message, int triesLeft, String expressionDetails) {
|
||||
super("Error while verifying result with " + triesLeft + " tries remaining: " + message);
|
||||
this.triesLeft = triesLeft;
|
||||
this.expressionDetails = expressionDetails;
|
||||
}
|
||||
|
||||
public ResultVerificationError(Throwable throwable, int triesLeft, String expressionDetails) {
|
||||
super("Error while verifying result with " + triesLeft + " tries remaining: " + throwable.getMessage(),throwable);
|
||||
this.triesLeft = triesLeft;
|
||||
this.expressionDetails = expressionDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
public int getTriesLeft() {
|
||||
return triesLeft;
|
||||
}
|
||||
|
||||
public Serializable getExpressionDetails() {
|
||||
return expressionDetails;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
/**
|
||||
* Implementors of this type can have variables set on them for later use.
|
||||
*/
|
||||
public interface VariableInjectable {
|
||||
|
||||
/**
|
||||
* Set a variable by name.
|
||||
*/
|
||||
<V> void setVariable(String name, V value);
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import io.nosqlbench.engine.api.metrics.EndToEndMetricsAdapterUtil.MSG_SEQ_ERROR_SIMU_TYPE;
|
||||
import io.nosqlbench.adapters.api.metrics.EndToEndMetricsAdapterUtil.MSG_SEQ_ERROR_SIMU_TYPE;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
|
||||
import java.util.ArrayDeque;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import com.codahale.metrics.Counter;
|
||||
|
@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import com.codahale.metrics.Timer;
|
||||
import com.codahale.metrics.Timer.Context;
|
||||
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.specifications;
|
||||
package io.nosqlbench.adapters.api.specifications;
|
||||
|
||||
import io.nosqlbench.api.content.Content;
|
||||
import io.nosqlbench.api.content.NBIO;
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.api.config.params.ParamsParser;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
|
||||
/**
|
||||
* This type simply captures (by extension) any optional decorator
|
||||
* interfaces which may be implemented by a {@link io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter}.
|
||||
* interfaces which may be implemented by a {@link DriverAdapter}.
|
||||
* Thus, it is mostly for documentation.
|
||||
*
|
||||
* Decorator interfaces are used within NoSQLBench where implementations are truly optional,
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
/**
|
||||
* Provide a way to configure a target object of type T, given an enumeration which describes the distinct property
|
@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.api.config.NBLabels;
|
||||
import io.nosqlbench.api.config.fieldreaders.DynamicFieldReader;
|
||||
@ -23,7 +24,9 @@ import io.nosqlbench.api.config.fieldreaders.StaticFieldReader;
|
||||
import io.nosqlbench.api.config.standard.NBConfigError;
|
||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.templating.ObjectCache;
|
||||
import io.nosqlbench.engine.api.templating.ParsedTemplateMap;
|
||||
import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
import io.nosqlbench.engine.api.templating.binders.ArrayBinder;
|
||||
import io.nosqlbench.engine.api.templating.binders.ListBinder;
|
||||
import io.nosqlbench.engine.api.templating.binders.OrderedMapBinder;
|
||||
@ -428,6 +431,10 @@ public class ParsedOp implements LongFunction<Map<String, ?>>, NBLabeledElement,
|
||||
return this.tmap.getAsStringTemplate(fieldname);
|
||||
}
|
||||
|
||||
public Optional<ParsedTemplateString> takeAsOptionalStringTemplate(String fieldname) {
|
||||
return this.tmap.takeAsOptionalStringTemplate(fieldname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the named static field value, or return the provided default, but throw an exception if
|
||||
* the named field is dynamic.
|
||||
@ -928,4 +935,8 @@ public class ParsedOp implements LongFunction<Map<String, ?>>, NBLabeledElement,
|
||||
public NBLabels getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public Map<String, String> getBindPoints() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
|
||||
import org.apache.commons.text.StrLookup;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.util;
|
||||
package io.nosqlbench.adapters.api.util;
|
||||
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.util;
|
||||
package io.nosqlbench.adapters.api.util;
|
||||
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Timer;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.api.config.NBLabels;
|
||||
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
|
||||
import io.nosqlbench.api.errors.MVELCompilationError;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.metrics.ThreadLocalNamedTimers;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import org.mvel2.MVEL;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
*
|
||||
* See {@link OpDispenser} for details on how to use this type.
|
||||
* <p>
|
||||
* Some details are tracked per op template, which aligns to the life-cycle of the op dispenser.
|
||||
* Thus, each op dispenser is where the stats for all related operations are kept.
|
||||
*
|
||||
* @param <T> The type of operation
|
||||
*/
|
||||
public abstract class BaseOpDispenser<T extends Op, S> implements OpDispenser<T>, NBLabeledElement {
|
||||
|
||||
private final String opName;
|
||||
private Serializable expectedResultExpression;
|
||||
protected final DriverAdapter<T, S> adapter;
|
||||
private final NBLabels labels;
|
||||
private boolean instrument;
|
||||
private Histogram resultSizeHistogram;
|
||||
private Timer successTimer;
|
||||
private Timer errorTimer;
|
||||
private final String[] timerStarts;
|
||||
private final String[] timerStops;
|
||||
|
||||
protected BaseOpDispenser(final DriverAdapter<T, S> adapter, final ParsedOp op) {
|
||||
opName = op.getName();
|
||||
this.adapter = adapter;
|
||||
labels = op.getLabels();
|
||||
|
||||
this.timerStarts = op.takeOptionalStaticValue("start-timers", String.class)
|
||||
.map(s -> s.split(", *"))
|
||||
.orElse(null);
|
||||
|
||||
this.timerStops = op.takeOptionalStaticValue("stop-timers", String.class)
|
||||
.map(s -> s.split(", *"))
|
||||
.orElse(null);
|
||||
|
||||
if (null != timerStarts)
|
||||
for (final String timerStart : this.timerStarts) ThreadLocalNamedTimers.addTimer(op, timerStart);
|
||||
this.configureInstrumentation(op);
|
||||
this.configureResultExpectations(op);
|
||||
}
|
||||
|
||||
public Serializable getExpectedResultExpression() {
|
||||
return expectedResultExpression;
|
||||
}
|
||||
|
||||
private void configureResultExpectations(ParsedOp op) {
|
||||
op.getOptionalStaticValue("expected-result", String.class)
|
||||
.map(this::compileExpectedResultExpression)
|
||||
.ifPresent(result -> this.expectedResultExpression = result);
|
||||
}
|
||||
|
||||
private Serializable compileExpectedResultExpression(String expectedResultExpression) {
|
||||
try {
|
||||
return MVEL.compileExpression(expectedResultExpression);
|
||||
} catch (Exception e) {
|
||||
throw new MVELCompilationError(
|
||||
String.format("Failed to compile expected-result expression: \"%s\"", expectedResultExpression), e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String getOpName() {
|
||||
return this.opName;
|
||||
}
|
||||
|
||||
public DriverAdapter<T, S> getAdapter() {
|
||||
return this.adapter;
|
||||
}
|
||||
|
||||
private void configureInstrumentation(final ParsedOp pop) {
|
||||
instrument = pop.takeStaticConfigOr("instrument", false);
|
||||
if (this.instrument) {
|
||||
final int hdrDigits = pop.getStaticConfigOr("hdr_digits", 4).intValue();
|
||||
successTimer = ActivityMetrics.timer(pop, "success",hdrDigits);
|
||||
errorTimer = ActivityMetrics.timer(pop, "error", hdrDigits);
|
||||
resultSizeHistogram = ActivityMetrics.histogram(pop, "resultset-size", hdrDigits);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(final long cycleValue) {
|
||||
if (null != timerStarts) ThreadLocalNamedTimers.TL_INSTANCE.get().start(this.timerStarts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(final long cycleValue, final long nanoTime, final long resultSize) {
|
||||
if (this.instrument) {
|
||||
this.successTimer.update(nanoTime, TimeUnit.NANOSECONDS);
|
||||
if (-1 < resultSize) this.resultSizeHistogram.update(resultSize);
|
||||
}
|
||||
if (null != timerStops) ThreadLocalNamedTimers.TL_INSTANCE.get().stop(this.timerStops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final long cycleValue, final long resultNanos, final Throwable t) {
|
||||
|
||||
if (this.instrument) this.errorTimer.update(resultNanos, TimeUnit.NANOSECONDS);
|
||||
if (null != timerStops) ThreadLocalNamedTimers.TL_INSTANCE.get().stop(this.timerStops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBLabels getLabels() {
|
||||
return this.labels;
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
|
||||
public class DryRunOp implements RunnableOp {
|
||||
|
||||
private final Op op;
|
||||
|
||||
public DryRunOp(Op op) {
|
||||
this.op = op;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
|
||||
public class DryRunOpDispenserWrapper extends BaseOpDispenser<Op, Object> {
|
||||
|
||||
private final OpDispenser<? extends Op> realDispenser;
|
||||
|
||||
public DryRunOpDispenserWrapper(DriverAdapter<Op,Object> adapter, ParsedOp pop, OpDispenser<? extends Op> realDispenser) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
@Override
|
||||
public DryRunOp apply(long cycle) {
|
||||
Op op = realDispenser.apply(cycle);
|
||||
return new DryRunOp(op);
|
||||
}
|
||||
}
|
@ -387,9 +387,7 @@ blocks:
|
||||
{
|
||||
"name": "namedblock1--op2",
|
||||
"op": {
|
||||
"stmt": "insert into bar.table (a,b,c) values (1,2,3);"
|
||||
},
|
||||
"params": {
|
||||
"stmt": "insert into bar.table (a,b,c) values (1,2,3);",
|
||||
"type": "batch"
|
||||
},
|
||||
"tags": {
|
||||
@ -462,9 +460,7 @@ blocks:
|
||||
{
|
||||
"name": "block1--op2",
|
||||
"op": {
|
||||
"stmt": "insert into bar.table (a,b,c) values (1,2,3);"
|
||||
},
|
||||
"params": {
|
||||
"stmt": "insert into bar.table (a,b,c) values (1,2,3);",
|
||||
"type": "batch"
|
||||
},
|
||||
"tags": {
|
||||
|
@ -5,33 +5,11 @@ templating language.
|
||||
|
||||
Template variables are resolved in the workload after the on-disk format is loaded and before yaml parsing.
|
||||
|
||||
## angle bracket value with defaults
|
||||
|
||||
*yaml:*
|
||||
```yaml
|
||||
name: <<myname,thedefault>>
|
||||
desc: <<mydesc:mydescription>>
|
||||
```
|
||||
|
||||
*json:*
|
||||
```json
|
||||
|
||||
{
|
||||
"name": "thedefault",
|
||||
"desc": "mydescription"
|
||||
}
|
||||
```
|
||||
|
||||
*ops:*
|
||||
```json
|
||||
|
||||
[]
|
||||
```
|
||||
|
||||
It's easier on syntax checkers if you use this form.
|
||||
|
||||
## call form with defaults
|
||||
|
||||
This is the preferred form. It's easier on syntax checkers.
|
||||
|
||||
|
||||
*yaml:*
|
||||
```yaml
|
||||
name: TEMPLATE(myname,thedefault)
|
||||
@ -92,3 +70,52 @@ name: TEMPLATE(myname,)
|
||||
|
||||
[]
|
||||
```
|
||||
|
||||
## call form with default value specified once
|
||||
|
||||
*yaml:*
|
||||
```yaml
|
||||
name: TEMPLATE(myname,default)
|
||||
description: This is the description for name 'TEMPLATE(myname)'
|
||||
```
|
||||
|
||||
*json:*
|
||||
```json
|
||||
|
||||
{
|
||||
"name": default,
|
||||
"description": "This is the description for name 'default'"
|
||||
}
|
||||
```
|
||||
|
||||
*ops:*
|
||||
```json
|
||||
|
||||
[]
|
||||
```
|
||||
|
||||
## angle bracket value with defaults
|
||||
|
||||
This form is deprecated! It conflicts with the YAML syntax for anchors and aliases. It will be
|
||||
removed in the next major version.
|
||||
|
||||
*yaml:*
|
||||
```yaml
|
||||
name: <<myname,thedefault>>
|
||||
desc: <<mydesc:mydescription>>
|
||||
```
|
||||
|
||||
*json:*
|
||||
```json
|
||||
|
||||
{
|
||||
"name": "thedefault",
|
||||
"desc": "mydescription"
|
||||
}
|
||||
```
|
||||
|
||||
*ops:*
|
||||
```json
|
||||
|
||||
[]
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig;
|
||||
package io.nosqlbench.adapters.api.activityconfig;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig;
|
||||
package io.nosqlbench.adapters.api.activityconfig;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDoc;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDoc;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.virtdata.core.bindings.DataMapper;
|
||||
import io.nosqlbench.virtdata.core.bindings.VirtData;
|
@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsBlock;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDoc;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsBlock;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDoc;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
@ -14,10 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.*;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsBlock;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDoc;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.rawyaml;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
@ -46,7 +47,7 @@ public class RawYamlTemplateLoaderTest {
|
||||
RawOpsLoader ysl = new RawOpsLoader();
|
||||
RawOpsDocList erthing = ysl.loadPath("testdocs/docs_blocks_ops.yaml");
|
||||
List<RawOpsDoc> rawOpsDocs = erthing.getOpsDocs();
|
||||
assertThat(rawOpsDocs).hasSize(2);
|
||||
Assertions.assertThat(rawOpsDocs).hasSize(2);
|
||||
RawOpsDoc rawOpsDoc = rawOpsDocs.get(0);
|
||||
List<RawOpsBlock> blocks = rawOpsDoc.getBlocks();
|
||||
assertThat(rawOpsDoc.getName()).isEqualTo("doc1");
|
||||
@ -60,7 +61,7 @@ public class RawYamlTemplateLoaderTest {
|
||||
RawOpsLoader ysl = new RawOpsLoader();
|
||||
RawOpsDocList erthing = ysl.loadPath("testdocs/docs_blocks_ops.yaml");
|
||||
List<RawOpsDoc> rawOpsDocs = erthing.getOpsDocs();
|
||||
assertThat(rawOpsDocs).hasSize(2);
|
||||
Assertions.assertThat(rawOpsDocs).hasSize(2);
|
||||
RawOpsDoc rawOpsDoc = rawOpsDocs.get(0);
|
||||
List<RawOpsBlock> blocks = rawOpsDoc.getBlocks();
|
||||
assertThat(rawOpsDoc.getDesc()).isEqualTo(
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.specifications;
|
||||
package io.nosqlbench.adapters.api.activityconfig.specifications;
|
||||
|
||||
import io.nosqlbench.api.docsapi.BundledMarkdownManifest;
|
||||
import io.nosqlbench.api.docsapi.Docs;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.specifications;
|
||||
package io.nosqlbench.adapters.api.activityconfig.specifications;
|
||||
|
||||
import com.vladsch.flexmark.ast.FencedCodeBlock;
|
||||
import io.nosqlbench.nb.spectest.core.SpecTest;
|
@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.specifications;
|
||||
package io.nosqlbench.adapters.api.activityconfig.specifications;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawYamlLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawYamlLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.nb.spectest.api.STAssemblyValidator;
|
||||
import io.nosqlbench.nb.spectest.core.STNodeAssembly;
|
||||
import io.nosqlbench.nb.spectest.loaders.STDefaultLoader;
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.assertj.core.data.MapEntry;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -77,7 +78,7 @@ public class OpsDocListTest {
|
||||
public void testStmtInheritsBlockData() {
|
||||
OpsDoc doc0 = doclist.getStmtDocs().get(0);
|
||||
List<OpTemplate> ops1 = doc0.getBlocks().get(0).getOps();
|
||||
assertThat(ops1).hasSize(2);
|
||||
Assertions.assertThat(ops1).hasSize(2);
|
||||
|
||||
OpsBlock block0 = doc0.getBlocks().get(0);
|
||||
assertThat(block0.getBindings()).containsExactly(MapEntry.entry("b2","b2d"),MapEntry.entry("b1","b1d"));
|
||||
@ -121,15 +122,15 @@ public class OpsDocListTest {
|
||||
public void testStmtsGetter() {
|
||||
OpsDoc doc1 = doclist.getStmtDocs().get(1);
|
||||
List<OpTemplate> stmts = doc1.getOpTemplates();
|
||||
assertThat(stmts).hasSize(4);
|
||||
Assertions.assertThat(stmts).hasSize(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredStmts() {
|
||||
List<OpTemplate> stmts = doclist.getOps("");
|
||||
assertThat(stmts).hasSize(6);
|
||||
Assertions.assertThat(stmts).hasSize(6);
|
||||
stmts = doclist.getOps("root1:value23");
|
||||
assertThat(stmts).hasSize(2);
|
||||
Assertions.assertThat(stmts).hasSize(2);
|
||||
}
|
||||
|
||||
}
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
package io.nosqlbench.adapters.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CompoundCycleFunctionTest {
|
||||
|
||||
private final GroovyCycleFunction<Boolean> truthy = new GroovyCycleFunction<>("truthy", "true;", Map.of(), List.of());
|
||||
private final GroovyCycleFunction<Boolean> falsy = new GroovyCycleFunction<>("falsy", "false;", Map.of(), List.of());
|
||||
|
||||
@Test
|
||||
public void testReducerFirstOrLastResult() {
|
||||
CompoundCycleFunction<Boolean> justB = new CompoundCycleFunction<>((a, b) -> b, truthy, falsy);
|
||||
assertThat(justB.apply(2)).isEqualTo(false);
|
||||
|
||||
CompoundCycleFunction<Boolean> justA = new CompoundCycleFunction<>((a, b) -> a, truthy, falsy);
|
||||
assertThat(justA.apply(2)).isEqualTo(true);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReducerAnyTrue() {
|
||||
CompoundCycleFunction<Boolean> trueOrFalse = new CompoundCycleFunction<>((a, b) -> a||b, truthy, falsy);
|
||||
assertThat(trueOrFalse.apply(2)).isEqualTo(true);
|
||||
|
||||
CompoundCycleFunction<Boolean> falseOrFalse = new CompoundCycleFunction<>((a, b) -> a||b, falsy, falsy);
|
||||
assertThat(falseOrFalse.apply(2)).isEqualTo(false);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReducerAllTrue() {
|
||||
CompoundCycleFunction<Boolean> trueAndFalse = new CompoundCycleFunction<>((a, b) -> a&&b, truthy, falsy);
|
||||
assertThat(trueAndFalse.apply(2)).isEqualTo(false);
|
||||
|
||||
CompoundCycleFunction<Boolean> trueAndTrue = new CompoundCycleFunction<>((a, b) -> a&&b, truthy, truthy);
|
||||
assertThat(trueAndTrue.apply(2)).isEqualTo(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.evalcontext;
|
||||
|
||||
import groovy.lang.MissingPropertyException;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
public class GroovyBooleanCycleFunctionTest {
|
||||
|
||||
@Test
|
||||
public void testBasicScript() {
|
||||
ParsedTemplateString parsedTemplate = new ParsedTemplateString("""
|
||||
true;
|
||||
""",
|
||||
Map.of("numbername", "NumberNameToString()")
|
||||
);
|
||||
List<String> imports = List.of();
|
||||
GroovyBooleanCycleFunction function = new GroovyBooleanCycleFunction("test1", parsedTemplate, imports);
|
||||
Boolean result = function.apply(2);
|
||||
assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUncaughtException() {
|
||||
ParsedTemplateString parsedTemplate = new ParsedTemplateString("""
|
||||
this_is_a_syntax_error
|
||||
""",
|
||||
Map.of("numbername", "NumberNameToString()")
|
||||
);
|
||||
List<String> imports = List.of();
|
||||
GroovyCycleFunction function = new GroovyBooleanCycleFunction("test2", parsedTemplate, imports);
|
||||
System.out.println(function);
|
||||
assertThatThrownBy(() -> function.apply(3L)).isInstanceOf(MissingPropertyException.class);
|
||||
}
|
||||
|
||||
}
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import io.nosqlbench.engine.api.metrics.EndToEndMetricsAdapterUtil.MSG_SEQ_ERROR_SIMU_TYPE;
|
||||
import io.nosqlbench.adapters.api.metrics.EndToEndMetricsAdapterUtil.MSG_SEQ_ERROR_SIMU_TYPE;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.metrics;
|
||||
package io.nosqlbench.adapters.api.metrics;
|
||||
|
||||
import com.codahale.metrics.Counter;
|
||||
import org.junit.jupiter.api.Test;
|
@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpData;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpData;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplateFormat;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.api.config.standard.ConfigModel;
|
||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
||||
import io.nosqlbench.api.config.standard.Param;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,11 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
package io.nosqlbench.adapters.api.templating;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.util;
|
||||
package io.nosqlbench.adapters.api.util;
|
||||
|
||||
import io.nosqlbench.api.engine.util.Tagged;
|
||||
import org.apache.logging.log4j.LogManager;
|
Loading…
Reference in New Issue
Block a user