partial progress to moving instrumentation

This commit is contained in:
Jonathan Shook
2023-10-04 23:26:24 -05:00
parent 835c74597a
commit 3ec511f61f
68 changed files with 2637 additions and 335 deletions

View File

@@ -115,9 +115,9 @@ public class PulsarAdapterMetrics {
//
private static class ProducerGaugeImpl implements Gauge<Object> {
private final Producer<?> producer;
private final Function<ProducerStats, Object> valueExtractor;
private final Function<ProducerStats, Double> valueExtractor;
ProducerGaugeImpl(final Producer<?> producer, final Function<ProducerStats, Object> valueExtractor) {
ProducerGaugeImpl(final Producer<?> producer, final Function<ProducerStats, Double> valueExtractor) {
this.producer = producer;
this.valueExtractor = valueExtractor;
}
@@ -131,20 +131,20 @@ public class PulsarAdapterMetrics {
}
}
}
private static Gauge<Object> producerSafeExtractMetric(final Producer<?> producer, final Function<ProducerStats, Object> valueExtractor) {
private static Gauge<Double> producerSafeExtractMetric(final Producer<?> producer, final Function<ProducerStats, Double> valueExtractor) {
return new ProducerGaugeImpl(producer, valueExtractor);
}
public void registerProducerApiMetrics(final Producer<?> producer) {
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_bytes_sent",
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> s.getTotalBytesSent() + s.getNumBytesSent()));
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> (double) s.getTotalBytesSent() + s.getNumBytesSent()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_msg_sent",
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> s.getTotalMsgsSent() + s.getNumMsgsSent()));
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> (double) s.getTotalMsgsSent() + s.getNumMsgsSent()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_send_failed",
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> s.getTotalSendFailed() + s.getNumSendFailed()));
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> (double) s.getTotalSendFailed() + s.getNumSendFailed()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_ack_received",
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> s.getTotalAcksReceived() + s.getNumAcksReceived()));
PulsarAdapterMetrics.producerSafeExtractMetric(producer, s -> (double) s.getTotalAcksReceived() + s.getNumAcksReceived()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "send_bytes_rate",
PulsarAdapterMetrics.producerSafeExtractMetric(producer, ProducerStats::getSendBytesRate));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "send_msg_rate",
@@ -158,9 +158,9 @@ public class PulsarAdapterMetrics {
//
private static class ConsumerGaugeImpl implements Gauge<Object> {
private final Consumer<?> consumer;
private final Function<ConsumerStats, Object> valueExtractor;
private final Function<ConsumerStats, Double> valueExtractor;
ConsumerGaugeImpl(final Consumer<?> consumer, final Function<ConsumerStats, Object> valueExtractor) {
ConsumerGaugeImpl(final Consumer<?> consumer, final Function<ConsumerStats, Double> valueExtractor) {
this.consumer = consumer;
this.valueExtractor = valueExtractor;
}
@@ -175,23 +175,23 @@ public class PulsarAdapterMetrics {
}
}
}
static Gauge<Object> consumerSafeExtractMetric(final Consumer<?> consumer, final Function<ConsumerStats, Object> valueExtractor) {
static Gauge<Double> consumerSafeExtractMetric(final Consumer<?> consumer, final Function<ConsumerStats, Double> valueExtractor) {
return new ConsumerGaugeImpl(consumer, valueExtractor);
}
public void registerConsumerApiMetrics(final Consumer<?> consumer, final String pulsarApiMetricsPrefix) {
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_bytes_recv",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> s.getTotalBytesReceived() + s.getNumBytesReceived()));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double) s.getTotalBytesReceived() + s.getNumBytesReceived()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_msg_recv",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> s.getTotalMsgsReceived() + s.getNumMsgsReceived()));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double)s.getTotalMsgsReceived() + s.getNumMsgsReceived()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_recv_failed",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> s.getTotalReceivedFailed() + s.getNumReceiveFailed()));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double) s.getTotalReceivedFailed() + s.getNumReceiveFailed()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "total_acks_sent",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> s.getTotalAcksSent() + s.getNumAcksSent()));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double) s.getTotalAcksSent() + s.getNumAcksSent()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "recv_bytes_rate",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, ConsumerStats::getRateBytesReceived));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double) s.getRateBytesReceived()));
ActivityMetrics.gauge(this.pulsarBaseOpDispenser, "recv_msg_rate",
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, ConsumerStats::getRateMsgsReceived));
PulsarAdapterMetrics.consumerSafeExtractMetric(consumer, s -> (double) s.getRateMsgsReceived()));
}
}

View File

@@ -0,0 +1,76 @@
fixtures {
# grid-columns:3
tooltip: Fixtures are the standard set of interfaces that a scenario invocation \
needs to communicate with any other element or do anything at all. Fixtures are \
stateful and disposable, i.e. do not reuse them more than once.
io {
label: IO Trace Buffers
tooltip: in the NBSceneBuffer variant of fixtures, IO streams are wrapped in a \
tracing fixture which intercepts and records all IO in and out. This is done \
opaquely to the scenario logic.
# grid-columns:1
in <- tbuf.in
out -> tbuf.out
err -> tbuf.err
tbuf {
label: "Assigned IO Streams"
tooltip: Normal stdin stdout and stderr IO streams are provided for use by scripted \
and compiled scenario logic.
# grid-columns:1
in
out
err
}
}
APIs {
grid-columns:2
# style.stroke-width: 0
controller {
tooltip: The controller is an Activity Controller which enables \
full control of activities, including defining, starting, stopping, \
dynamic modification of parameters, blocking, etc. It is the controller \
that is responsible for activity lifecycles.
}
params {
tooltip: Scenario parameters are given to the scenario log as part of the \
fixtures. These can come from the command line or scripting environment.
}
component {
label: <component>
tooltip: The component represents a node in a runtime hierarchy \
to which all metrics and other fixtures are attached. Each scenario \
runs within a component context, and all component APIs are exposed \
directly within the execution context as services.
}
extensions {
tooltip: Extensions are bundled capabilities which can be pulled into \
a scenario if and when needed. Contributors can build extensions \
which provide additional services, and these can be loaded into either \
scripted environments with duck-typing, or into compiled code with type \
safety. They are also available to result verifier logic when appropriate.
}
}
}
logic {
}
logic <- fixtures.io.in : reads
logic -> fixtures.io.out : writes
logic -> fixtures.io.err : writes
system {
}
fixtures.io.tbuf.in <- system : reads
fixtures.io.tbuf.out -> system : writes
fixtures.io.tbuf.err -> system : writes
#IO\nbuffers -. "embed" .-> fixtures
# params --> fixtures
# fixtures --> Scenario\ninstance
# Scenario\ninstance --> used\nfixtures
# used\nfixtures -. extract .-> IO\ntraces

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,9 @@
direction: right
fixtures {
params
buffers
}
fixtures --> scenario --> result

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" d2Version="v0.6.1" preserveAspectRatio="xMinYMin meet" viewBox="0 0 732 454"><svg id="d2-svg" class="d2-1046006693" width="732" height="454" viewBox="-89 -89 732 454"><rect x="-89.000000" y="-89.000000" width="732.000000" height="454.000000" rx="0.000000" class=" fill-N7" stroke-width="0" /><style type="text/css"><![CDATA[
.d2-1046006693 .text {
font-family: "d2-1046006693-font-regular";
}
@font-face {
font-family: d2-1046006693-font-regular;
src: url("data:application/font-woff;base64,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");
}
.d2-1046006693 .text-bold {
font-family: "d2-1046006693-font-bold";
}
@font-face {
font-family: d2-1046006693-font-bold;
src: url("data:application/font-woff;base64,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");
}]]></style><style type="text/css"><![CDATA[.shape {
shape-rendering: geometricPrecision;
stroke-linejoin: round;
}
.connection {
stroke-linecap: round;
stroke-linejoin: round;
}
.blend {
mix-blend-mode: multiply;
opacity: 0.5;
}
.d2-1046006693 .fill-N1{fill:#0A0F25;}
.d2-1046006693 .fill-N2{fill:#676C7E;}
.d2-1046006693 .fill-N3{fill:#9499AB;}
.d2-1046006693 .fill-N4{fill:#CFD2DD;}
.d2-1046006693 .fill-N5{fill:#DEE1EB;}
.d2-1046006693 .fill-N6{fill:#EEF1F8;}
.d2-1046006693 .fill-N7{fill:#FFFFFF;}
.d2-1046006693 .fill-B1{fill:#0D32B2;}
.d2-1046006693 .fill-B2{fill:#0D32B2;}
.d2-1046006693 .fill-B3{fill:#E3E9FD;}
.d2-1046006693 .fill-B4{fill:#E3E9FD;}
.d2-1046006693 .fill-B5{fill:#EDF0FD;}
.d2-1046006693 .fill-B6{fill:#F7F8FE;}
.d2-1046006693 .fill-AA2{fill:#4A6FF3;}
.d2-1046006693 .fill-AA4{fill:#EDF0FD;}
.d2-1046006693 .fill-AA5{fill:#F7F8FE;}
.d2-1046006693 .fill-AB4{fill:#EDF0FD;}
.d2-1046006693 .fill-AB5{fill:#F7F8FE;}
.d2-1046006693 .stroke-N1{stroke:#0A0F25;}
.d2-1046006693 .stroke-N2{stroke:#676C7E;}
.d2-1046006693 .stroke-N3{stroke:#9499AB;}
.d2-1046006693 .stroke-N4{stroke:#CFD2DD;}
.d2-1046006693 .stroke-N5{stroke:#DEE1EB;}
.d2-1046006693 .stroke-N6{stroke:#EEF1F8;}
.d2-1046006693 .stroke-N7{stroke:#FFFFFF;}
.d2-1046006693 .stroke-B1{stroke:#0D32B2;}
.d2-1046006693 .stroke-B2{stroke:#0D32B2;}
.d2-1046006693 .stroke-B3{stroke:#E3E9FD;}
.d2-1046006693 .stroke-B4{stroke:#E3E9FD;}
.d2-1046006693 .stroke-B5{stroke:#EDF0FD;}
.d2-1046006693 .stroke-B6{stroke:#F7F8FE;}
.d2-1046006693 .stroke-AA2{stroke:#4A6FF3;}
.d2-1046006693 .stroke-AA4{stroke:#EDF0FD;}
.d2-1046006693 .stroke-AA5{stroke:#F7F8FE;}
.d2-1046006693 .stroke-AB4{stroke:#EDF0FD;}
.d2-1046006693 .stroke-AB5{stroke:#F7F8FE;}
.d2-1046006693 .background-color-N1{background-color:#0A0F25;}
.d2-1046006693 .background-color-N2{background-color:#676C7E;}
.d2-1046006693 .background-color-N3{background-color:#9499AB;}
.d2-1046006693 .background-color-N4{background-color:#CFD2DD;}
.d2-1046006693 .background-color-N5{background-color:#DEE1EB;}
.d2-1046006693 .background-color-N6{background-color:#EEF1F8;}
.d2-1046006693 .background-color-N7{background-color:#FFFFFF;}
.d2-1046006693 .background-color-B1{background-color:#0D32B2;}
.d2-1046006693 .background-color-B2{background-color:#0D32B2;}
.d2-1046006693 .background-color-B3{background-color:#E3E9FD;}
.d2-1046006693 .background-color-B4{background-color:#E3E9FD;}
.d2-1046006693 .background-color-B5{background-color:#EDF0FD;}
.d2-1046006693 .background-color-B6{background-color:#F7F8FE;}
.d2-1046006693 .background-color-AA2{background-color:#4A6FF3;}
.d2-1046006693 .background-color-AA4{background-color:#EDF0FD;}
.d2-1046006693 .background-color-AA5{background-color:#F7F8FE;}
.d2-1046006693 .background-color-AB4{background-color:#EDF0FD;}
.d2-1046006693 .background-color-AB5{background-color:#F7F8FE;}
.d2-1046006693 .color-N1{color:#0A0F25;}
.d2-1046006693 .color-N2{color:#676C7E;}
.d2-1046006693 .color-N3{color:#9499AB;}
.d2-1046006693 .color-N4{color:#CFD2DD;}
.d2-1046006693 .color-N5{color:#DEE1EB;}
.d2-1046006693 .color-N6{color:#EEF1F8;}
.d2-1046006693 .color-N7{color:#FFFFFF;}
.d2-1046006693 .color-B1{color:#0D32B2;}
.d2-1046006693 .color-B2{color:#0D32B2;}
.d2-1046006693 .color-B3{color:#E3E9FD;}
.d2-1046006693 .color-B4{color:#E3E9FD;}
.d2-1046006693 .color-B5{color:#EDF0FD;}
.d2-1046006693 .color-B6{color:#F7F8FE;}
.d2-1046006693 .color-AA2{color:#4A6FF3;}
.d2-1046006693 .color-AA4{color:#EDF0FD;}
.d2-1046006693 .color-AA5{color:#F7F8FE;}
.d2-1046006693 .color-AB4{color:#EDF0FD;}
.d2-1046006693 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]></style><g id="fixtures"><g class="shape" ><rect x="12.000000" y="12.000000" width="198.000000" height="252.000000" class=" stroke-B1 fill-B4" style="stroke-width:2;" /></g><text x="111.000000" y="45.000000" class="text fill-N1" style="text-anchor:middle;font-size:28px">fixtures</text></g><g id="scenario"><g class="shape" ><rect x="280.000000" y="105.000000" width="106.000000" height="66.000000" class=" stroke-B1 fill-B6" style="stroke-width:2;" /></g><text x="333.000000" y="143.500000" class="text-bold fill-N1" style="text-anchor:middle;font-size:16px">scenario</text></g><g id="result"><g class="shape" ><rect x="456.000000" y="105.000000" width="86.000000" height="66.000000" class=" stroke-B1 fill-B6" style="stroke-width:2;" /></g><text x="499.000000" y="143.500000" class="text-bold fill-N1" style="text-anchor:middle;font-size:16px">result</text></g><g id="fixtures.params"><g class="shape" ><rect x="62.000000" y="62.000000" width="98.000000" height="66.000000" class=" stroke-B1 fill-B5" style="stroke-width:2;" /></g><text x="111.000000" y="100.500000" class="text-bold fill-N1" style="text-anchor:middle;font-size:16px">params</text></g><g id="fixtures.buffers"><g class="shape" ><rect x="63.000000" y="148.000000" width="95.000000" height="66.000000" class=" stroke-B1 fill-B5" style="stroke-width:2;" /></g><text x="110.500000" y="186.500000" class="text-bold fill-N1" style="text-anchor:middle;font-size:16px">buffers</text></g><g id="(fixtures -&gt; scenario)[0]"><marker id="mk-3488378134" markerWidth="10.000000" markerHeight="12.000000" refX="7.000000" refY="6.000000" viewBox="0.000000 0.000000 10.000000 12.000000" orient="auto" markerUnits="userSpaceOnUse"> <polygon points="0.000000,0.000000 10.000000,6.000000 0.000000,12.000000" class="connection fill-B1" stroke-width="2" /> </marker><path d="M 212.000000 138.000000 L 276.000000 138.000000" fill="none" class="connection stroke-B1" style="stroke-width:2;" marker-end="url(#mk-3488378134)" mask="url(#d2-1046006693)" /></g><g id="(scenario -&gt; result)[0]"><path d="M 388.000000 138.000000 L 452.000000 138.000000" fill="none" class="connection stroke-B1" style="stroke-width:2;" marker-end="url(#mk-3488378134)" mask="url(#d2-1046006693)" /></g><mask id="d2-1046006693" maskUnits="userSpaceOnUse" x="-89" y="-89" width="732" height="454">
<rect x="-89" y="-89" width="732" height="454" fill="white"></rect>
<rect x="67.500000" y="17.000000" width="87" height="36" fill="rgba(0,0,0,0.75)"></rect>
<rect x="302.500000" y="127.500000" width="61" height="21" fill="rgba(0,0,0,0.75)"></rect>
<rect x="478.500000" y="127.500000" width="41" height="21" fill="rgba(0,0,0,0.75)"></rect>
<rect x="84.500000" y="84.500000" width="53" height="21" fill="rgba(0,0,0,0.75)"></rect>
<rect x="85.500000" y="170.500000" width="50" height="21" fill="rgba(0,0,0,0.75)"></rect>
</mask></svg></svg>

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -27,8 +27,6 @@ import io.nosqlbench.api.engine.metrics.instruments.NBMetricTimer;
public class ComponentActivityInstrumentation implements ActivityInstrumentation {
private static final String STRICTMETRICNAMES = "strictmetricnames";
private static final String WAIT_TIME = "_waittime";
private static final String SERVICE_TIME = "_servicetime";
private static final String RESPONSE_TIME = "_responsetime";

View File

@@ -91,7 +91,7 @@ public class HybridRateLimiter implements RateLimiter {
private String label;
private State state = State.Idle;
// metrics
private Gauge<Long> delayGauge;
private Gauge<Double> delayGauge;
private Gauge<Double> avgRateGauge;
private Gauge<Double> burstRateGauge;
private TokenPool tokens;

View File

@@ -42,7 +42,7 @@ public enum RateLimiters {
return RateLimiters.createOrUpdate(def, label, null, new RateSpec(specString));
}
public static class WaitTimeGauge implements Gauge<Long> {
public static class WaitTimeGauge implements Gauge<Double> {
private final RateLimiter rateLimiter;
@@ -51,8 +51,8 @@ public enum RateLimiters {
}
@Override
public Long getValue() {
return this.rateLimiter.getTotalWaitTime();
public Double getValue() {
return (double)this.rateLimiter.getTotalWaitTime();
}
}

View File

@@ -404,6 +404,11 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
final LoggerConfigData classicConfigs : options.getClassicHistoConfigs())
ActivityMetrics.addClassicHistos(sessionName, classicConfigs.pattern, classicConfigs.file, classicConfigs.interval);
if (options.getConsoleLogLevel().isGreaterOrEqualTo(NBLogLevel.WARN)) {
options.setWantsStackTraces(true);
NBCLI.logger.debug(() -> "enabling stack traces since log level is " + options.getConsoleLogLevel());
}
// client machine metrics; TODO: modify pollInterval
this.clientMetricChecker = new ClientSystemMetricChecker(10);
registerLoadAvgMetrics();
@@ -416,24 +421,13 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
// intentionally not shown for warn-only
NBCLI.logger.info(() -> "console logging level is " + options.getConsoleLogLevel());
final ScenariosExecutor scenariosExecutor = new ScenariosExecutor("executor-" + sessionName, 1);
if (options.getConsoleLogLevel().isGreaterOrEqualTo(NBLogLevel.WARN)) {
options.setWantsStackTraces(true);
NBCLI.logger.debug(() -> "enabling stack traces since log level is " + options.getConsoleLogLevel());
}
// intentionally not shown for warn-only
NBCLI.logger.info(() -> "console logging level is " + options.getConsoleLogLevel());
/**
* At this point, the command stream from the CLI should be handed into the session, and the session should
* marshal and transform it for any scenario invocations directly.
*/
NBSession session = new NBSession(
new NBBaseComponent(null),
sessionName,
options.getProgressSpec(),
options.wantsShowScript()
sessionName
);
ExecutionResult sessionResult = session.apply(options.getCommands());
sessionResult.printSummary(System.out);

View File

@@ -68,6 +68,7 @@ public class BasicScriptBuffer implements ScriptBuffer {
sb.append("\n");
}
break;
case java:
case start: // start activity
case run: // run activity
case await: // await activity

View File

@@ -146,7 +146,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
activitylogger.debug("FORCE STOP/before alias=(" + activity.getAlias() + ")");
activity.setRunState(RunState.Stopped);
executorService.shutdown();
executorService.shutdownNow();
requestStopMotors();
int divisor = 100;
@@ -401,7 +401,6 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
shutdownHook = new ActivityExecutorShutdownHook(this);
Runtime.getRuntime().addShutdownHook(shutdownHook);
long startAt = System.currentTimeMillis();
Annotators.recordAnnotation(Annotation.newBuilder()
.element(this)

View File

@@ -40,7 +40,7 @@ public class ActivityLoader {
public synchronized Activity loadActivity(ActivityDef activityDef, final NBComponent parent) {
activityDef= activityDef.deprecate("yaml","workload").deprecate("type","driver");
final Activity activity = new StandardActivityType(activityDef, parent).getAssembledActivity(activityDef, this.activityMap, parent);
final Activity activity = new StandardActivityType<>(activityDef, parent).getAssembledActivity(activityDef, this.activityMap, parent);
this.activityMap.put(activity.getAlias(),activity);
ActivityLoader.logger.debug("Resolved activity for alias '{}'", activityDef.getAlias());
return activity;

View File

@@ -325,7 +325,7 @@ public class ActivitiesController extends NBBaseComponent {
*/
public synchronized void forceStopScenario(int waitTimeMillis, boolean rethrow) {
logger.debug("force stopping scenario {}", description());
activityInfoMap.values().forEach(a -> a.getActivityExecutor().forceStopActivity(10000));
activityInfoMap.values().forEach(a -> a.getActivityExecutor().forceStopActivity(2000));
logger.debug("Scenario force stopped.");
}
@@ -451,19 +451,19 @@ public class ActivitiesController extends NBBaseComponent {
public void shutdown() {
logger.debug(() -> "Requesting ScenarioController shutdown.");
this.activitiesExecutor.shutdown();
try {
if (!this.activitiesExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
logger.info(() -> "Scenario is being forced to shutdown after waiting 5 seconds for graceful shutdown.");
this.activitiesExecutor.shutdownNow();
if (!this.activitiesExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
throw new RuntimeException("Unable to shutdown activities executor");
}
}
} catch (Exception e) {
logger.warn("There was an exception while trying to shutdown the ScenarioController:{}", e, e);
throw new RuntimeException(e);
}
this.activitiesExecutor.shutdownNow();
// try {
// if (!this.activitiesExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
// logger.info(() -> "Scenario is being forced to shutdown after waiting 5 seconds for graceful shutdown.");
// this.activitiesExecutor.shutdownNow();
// if (!this.activitiesExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
// logger.warn("Unable to shutdown activities executor gracefully");
// }
// }
// } catch (Exception e) {
// logger.warn("There was an exception while trying to shutdown the ScenarioController:{}", e, e);
// throw new RuntimeException(e);
// }
}
}

View File

@@ -78,11 +78,11 @@ public class NBDefaultSceneFixtures implements NBSceneFixtures {
this.in = in;
}
public static NBSceneFixtures ofDefault() {
public static NBSceneFixtures ofDefault(String name) {
return new NBDefaultSceneFixtures(
new ScriptParams(),
new NBSession(
new TestComponent("test", "test"), "test", "console:10s", false
new TestComponent("scene", name), "scene~"+name
),
new ActivitiesController(),
Extensions.ofNone(),
@@ -98,7 +98,7 @@ public class NBDefaultSceneFixtures implements NBSceneFixtures {
}
@Override
public NBComponent session() {
public NBComponent component() {
return session;
}

View File

@@ -16,6 +16,7 @@
package io.nosqlbench.engine.core.lifecycle.scenario.context;
import io.nosqlbench.api.config.standard.TestComponent;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.api.scripting.DiagReader;
import io.nosqlbench.engine.api.scripting.DiagWriter;
@@ -23,7 +24,6 @@ import io.nosqlbench.engine.core.lifecycle.scenario.execution.Extensions;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -42,15 +42,14 @@ public class NBSceneBuffer implements NBSceneFixtures {
stdinBuffer = new DiagReader(fixtures.in(), " stdin ");
}
@Override
public ScriptParams params() {
return fixtures.params();
}
@Override
public NBComponent session() {
return fixtures.session();
public NBComponent component() {
return fixtures.component();
}
@Override
@@ -69,7 +68,7 @@ public class NBSceneBuffer implements NBSceneFixtures {
}
@Override
public Writer err() {
public PrintWriter err() {
return stderrBuffer;
}
@@ -87,9 +86,16 @@ public class NBSceneBuffer implements NBSceneFixtures {
return log;
}
public String getIoLog() {
public String getIOLog() {
return String.join("",getTimedLogLines());
}
public NBSceneFixtures asFixtures() {
return (NBSceneFixtures) this;
}
public static NBSceneBuffer init(String name) {
TestComponent root = new TestComponent("scene", "self");
return new NBSceneBuffer(NBDefaultSceneFixtures.ofDefault(name));
}
}

View File

@@ -21,12 +21,11 @@ import io.nosqlbench.engine.core.lifecycle.scenario.execution.Extensions;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
public interface NBSceneFixtures {
ScriptParams params();
NBComponent session();
NBComponent component();
ActivitiesController controller();
@@ -34,8 +33,12 @@ public interface NBSceneFixtures {
PrintWriter out();
Writer err();
PrintWriter err();
Reader in();
public static NBSceneFixtures NEW(String sceneName) {
return NBDefaultSceneFixtures.ofDefault(sceneName);
}
}

View File

@@ -25,7 +25,7 @@ import java.util.Map;
public abstract class NBBaseScenario extends NBScenario {
public NBBaseScenario(NBComponent parentComponent, String scenarioName, Map<String, String> params, String progressInterval) {
super(parentComponent, scenarioName, params, progressInterval);
super(parentComponent, scenarioName);
}
@Override

View File

@@ -18,6 +18,7 @@ package io.nosqlbench.engine.core.lifecycle.scenario.execution;
import io.nosqlbench.api.annotations.Annotation;
import io.nosqlbench.api.annotations.Layer;
import io.nosqlbench.api.labels.NBLabels;
import io.nosqlbench.api.metadata.ScenarioMetadata;
import io.nosqlbench.api.metadata.SystemId;
import io.nosqlbench.components.NBBaseComponent;
@@ -26,12 +27,12 @@ import io.nosqlbench.components.NBComponentErrorHandler;
import io.nosqlbench.engine.core.annotation.Annotators;
import io.nosqlbench.engine.core.lifecycle.activity.ActivitiesProgressIndicator;
import io.nosqlbench.engine.core.lifecycle.scenario.context.ActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneBuffer;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneFixtures;
import io.nosqlbench.engine.core.lifecycle.scenario.script.NBScriptedScenario;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Map;
import java.util.function.Function;
/**
@@ -44,10 +45,9 @@ import java.util.function.Function;
* </OL>
*/
public abstract class NBScenario extends NBBaseComponent
implements Function<NBSceneFixtures, ScenarioResult>, NBComponentErrorHandler {
private final String scenarioName;
private final Map<String, String> params;
implements
Function<NBSceneBuffer, ScenarioResult>,
NBComponentErrorHandler {
protected Logger logger = LogManager.getLogger("SCENARIO");
private long startedAtMillis, endedAtMillis;
@@ -56,34 +56,24 @@ public abstract class NBScenario extends NBBaseComponent
private ActivitiesController activitiesController;
private Exception error;
private String progressInterval;
private String progressInterval = "console:10s";
private ActivitiesProgressIndicator activitiesProgressIndicator;
public NBScenario(
NBComponent parentComponent,
String scenarioName,
Map<String, String> params,
String progressInterval
) {
super(parentComponent);
this.scenarioName = scenarioName;
this.params = params;
this.progressInterval = progressInterval;
this.activitiesController = new ActivitiesController();
public NBScenario(NBComponent parentComponent, String scenarioName) {
super(parentComponent, NBLabels.forKV("scenario",scenarioName));
}
public String getScenarioName() {
return scenarioName;
return getLabels().asMap().get("scenario");
}
public void forceStopScenario(int i, boolean b) {
activitiesController.forceStopScenario(i,b);
}
public Map<String, String> getParams() {
return this.params;
}
// public Map<String, String> getParams() {
// return this.params;
// }
public ActivitiesController getActivitiesController() {
return this.activitiesController;
@@ -120,7 +110,8 @@ public abstract class NBScenario extends NBBaseComponent
* @return
*/
@Override
public final ScenarioResult apply(NBSceneFixtures sctx) {
public final ScenarioResult apply(NBSceneBuffer sctx) {
this.activitiesController=sctx.controller();
this.scenarioShutdownHook = new ScenarioShutdownHook(this);
Runtime.getRuntime().addShutdownHook(this.scenarioShutdownHook);
@@ -135,18 +126,18 @@ public abstract class NBScenario extends NBBaseComponent
.build()
);
if (!"disabled".equals(progressInterval))
if (!"disabled".equals(progressInterval) && progressInterval!=null && !progressInterval.isEmpty())
this.activitiesProgressIndicator = new ActivitiesProgressIndicator(activitiesController, this.progressInterval);
ScenarioResult result = null;
try {
runScenario(sctx);
runScenario(sctx.asFixtures());
final long awaitCompletionTime = 86400 * 365 * 1000L;
this.logger.debug("Awaiting completion of scenario and activities for {} millis.", awaitCompletionTime);
this.activitiesController.awaitCompletion(awaitCompletionTime);
} catch (Exception e) {
try {
activitiesController.forceStopScenario(5000, false);
activitiesController.forceStopScenario(3000, false);
} catch (final Exception eInner) {
this.logger.debug("Found inner exception while forcing stop with rethrow=false: {}", eInner);
throw new RuntimeException(e);
@@ -156,9 +147,9 @@ public abstract class NBScenario extends NBBaseComponent
this.activitiesController.shutdown();
this.endedAtMillis = System.currentTimeMillis();
result = new ScenarioResult(
sctx,
startedAtMillis,
endedAtMillis,
(error != null) ? error.toString() : "",
error
);
}
@@ -212,11 +203,15 @@ public abstract class NBScenario extends NBBaseComponent
private synchronized ScenarioMetadata getScenarioMetadata() {
if (null == this.scenarioMetadata) scenarioMetadata = new ScenarioMetadata(
startedAtMillis,
scenarioName,
getScenarioName(),
SystemId.getNodeId(),
SystemId.getNodeFingerprint()
);
return this.scenarioMetadata;
}
@Override
public String toString() {
return "SCENARIO (" + this.getClass().getSuperclass().getSimpleName()+") { scenarioName: "+getScenarioName()+" }";
}
}

View File

@@ -18,42 +18,39 @@ package io.nosqlbench.engine.core.lifecycle.scenario.execution;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneBuffer;
public class ScenarioResult {
public class ScenarioResult extends NBSceneBuffer {
private final long startedAt;
private final long endedAt;
private final String iolog;
private final Exception error;
public ScenarioResult(long startedAt, long endedAt, String iolog, Exception error) {
this.startedAt = startedAt;
this.endedAt = endedAt;
this.iolog = iolog;
this.error = error;
}
public ScenarioResult(ScenarioResult baseResult, NBSceneBuffer bufferedContext) {
this.startedAt = baseResult.startedAt;
this.endedAt = baseResult.endedAt;
String log = bufferedContext.getIoLog();
this.error = baseResult.error;
if (this.error!=null) {
log+=error.getMessage();
}
this.iolog = log;
private final Exception exception;
public ScenarioResult(NBSceneBuffer fixtures, long start, long end, Exception exception) {
super(fixtures);
this.startedAt=start;
this.endedAt=end;
this.exception =exception;
}
public Exception getException() {
return error;
return this.exception;
}
public String getIOLog() {
return iolog;
public static ScenarioResult ofError(Exception e, long now) {
return new ScenarioResult(NBSceneBuffer.init("error"),now,now,e);
}
@Override
public String toString() {
return ((error!=null)? "ERROR:" + error.toString() : "") +
getIOLog();
public void report() {
System.out.println(getIOLog());
if (exception!=null) {
if (exception instanceof RuntimeException rte) {
throw rte;
} else {
throw new RuntimeException(exception);
}
}
}
public void exitWithCode() {
if (exception!=null) {
System.exit(2);
}
}
}

View File

@@ -55,12 +55,15 @@ public class ScenariosExecutor extends NBBaseComponent {
}
public synchronized void execute(NBScenario scenario) {
execute(scenario,new ScriptParams());
}
public synchronized void execute(NBScenario scenario, Map<String,String> params) {
if (submitted.get(scenario.getScenarioName()) != null) {
throw new BasicError("Scenario " + scenario.getScenarioName() + " is already defined. Remove it first to reuse the name.");
}
NBSceneFixtures basecontext = new NBDefaultSceneFixtures(
ScriptParams.of(scenario.getParams()),
ScriptParams.of(params),
this.getParent(),
scenario.getActivitiesController(),
loadExtensions(),
@@ -71,7 +74,7 @@ public class ScenariosExecutor extends NBBaseComponent {
NBSceneBuffer bufferedContext = new NBSceneBuffer(basecontext);
Future<ScenarioResult> future = executor.submit(
() -> new ScenarioResult(scenario.apply(bufferedContext),bufferedContext) // combine basic execution data with trace
() -> scenario.apply(bufferedContext) // combine basic execution data with trace
);
SubmittedScenario s = new SubmittedScenario(scenario, future);
submitted.put(s.getName(), s);
@@ -177,7 +180,7 @@ public class ScenariosExecutor extends NBBaseComponent {
} catch (Exception e) {
long now = System.currentTimeMillis();
logger.debug("creating exceptional scenario result from getAsyncResultStatus");
oResult = Optional.of(new ScenarioResult(now, now, "errored output" + e.getMessage(), e));
oResult = Optional.of(ScenarioResult.ofError(e, now));
}
}

View File

@@ -25,6 +25,7 @@ import io.nosqlbench.engine.core.lifecycle.activity.ActivitiesProgressIndicator;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneFixtures;
import io.nosqlbench.engine.core.lifecycle.scenario.context.ScriptParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import io.nosqlbench.engine.core.lifecycle.scenario.script.bindings.PolyglotScenarioController;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine.Builder;
import org.graalvm.polyglot.EnvironmentAccess;
@@ -33,6 +34,7 @@ import org.graalvm.polyglot.PolyglotAccess;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -44,7 +46,7 @@ import java.nio.file.Paths;
import java.util.*;
public class NBScriptedScenario extends NBScenario {
private final Invocation invocation;
private final Invocation invocation = Invocation.EXECUTE_SCRIPT;
private Exception error;
@@ -79,20 +81,16 @@ public class NBScriptedScenario extends NBScenario {
public NBScriptedScenario(
final String scenarioName,
final String progressInterval,
Map<String, String> params,
NBComponent parentComponent,
Invocation invocation
NBComponent parentComponent
) {
super(parentComponent, scenarioName, params, progressInterval);
super(parentComponent, scenarioName);
this.scenarioName = scenarioName;
this.progressInterval = progressInterval;
this.parentComponent = parentComponent;
this.invocation = invocation;
}
public static NBScriptedScenario ofScripted(String name, Map<String, String> params, NBComponent parent, Invocation invocation) {
return new NBScriptedScenario(name, "console:10s",params,parent,invocation);
return new NBScriptedScenario(name, parent);
};
@@ -122,6 +120,7 @@ public class NBScriptedScenario extends NBScenario {
private void initializeScriptContext(NBSceneFixtures fixtures) {
BufferedScriptContext ctx = new BufferedScriptContext(fixtures);
this.scriptEngine.setContext(ctx);
ctx.getBindings(ScriptContext.ENGINE_SCOPE).put("scenario",new PolyglotScenarioController(fixtures.controller()));
}
private void initializeScriptingEngine() {
@@ -248,15 +247,15 @@ public class NBScriptedScenario extends NBScenario {
return "name:'" + scenarioName + '\'';
}
public void addScenarioScriptParams(final ScriptParams scenarioScriptParams) {
this.scenarioScriptParams = scenarioScriptParams;
}
// public void addScenarioScriptParams(final ScriptParams scenarioScriptParams) {
// this.scenarioScriptParams = scenarioScriptParams;
// }
public void addScenarioScriptParams(final Map<String, String> scriptParams) {
this.addScenarioScriptParams(new ScriptParams() {{
this.putAll(scriptParams);
}});
}
// public void addScenarioScriptParams(final Map<String, String> scriptParams) {
// this.addScenarioScriptParams(new ScriptParams() {{
// this.putAll(scriptParams);
// }});
// }
}

View File

@@ -0,0 +1,72 @@
/*
* 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.engine.core.lifecycle.session;
import io.nosqlbench.engine.cli.Cmd;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
public class CmdParamsBuffer {
private final Logger logger = LogManager.getLogger(CmdParamsBuffer.class);
private List<Cmd> cmds = new ArrayList<>();
public CmdParamsBuffer() {}
public CmdParamsBuffer(List<Cmd> cmds) {
this.cmds.addAll(cmds);
}
public void add(Cmd... cmd) {
this.cmds.addAll(Arrays.asList(cmd));
}
public Map<String,String> getGlobalParams() {
Map<String,String> params = new LinkedHashMap<>();
for (Cmd cmd : cmds) {
switch (cmd.getCmdType()) {
case script:
case fragment:
case java:
combineGlobalParams(params,cmd);
break;
default:
}
}
return params;
}
/**
* Merge the params from the command into the global params map, but ensure that users know
* if they are overwriting values, which could cause difficult to find bugs in their scripts.
*
* @param scriptParams The existing global params map
* @param cmd The command containing the new params to merge in
*/
private void combineGlobalParams(Map<String, String> scriptParams, Cmd cmd) {
for (String newkey : cmd.getParams().keySet()) {
String newvalue = cmd.getParams().get(newkey);
if (scriptParams.containsKey(newkey)) {
logger.warn("command '" + cmd.getCmdType() + "' overwrote param '" + newkey + " as " + newvalue);
}
scriptParams.put(newkey, newvalue);
}
}
}

View File

@@ -17,7 +17,9 @@
package io.nosqlbench.engine.core.lifecycle.session;
import io.nosqlbench.api.labels.NBLabeledElement;
import io.nosqlbench.api.spi.SimpleServiceLoader;
import io.nosqlbench.components.NBBaseComponent;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.components.NBComponentSubScope;
import io.nosqlbench.engine.cli.BasicScriptBuffer;
import io.nosqlbench.engine.cli.Cmd;
@@ -29,10 +31,14 @@ import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosExecutor;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosResults;
import io.nosqlbench.engine.core.lifecycle.scenario.script.NBScriptedScenario;
import io.nosqlbench.nb.annotations.Maturity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
@@ -44,8 +50,6 @@ import java.util.function.Function;
public class NBSession extends NBBaseComponent implements Function<List<Cmd>, ExecutionResult> {
private final static Logger logger = LogManager.getLogger(NBSession.class);
private final String sessionName;
private final String progressSpec;
private final boolean wantsDryRun;
public enum STATUS {
OK,
@@ -55,14 +59,10 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
public NBSession(
NBLabeledElement labelContext,
String sessionName,
String progressSpec,
boolean wantsDryRun
String sessionName
) {
super(null, labelContext.getLabels().and("session", sessionName));
this.sessionName = sessionName;
this.progressSpec = progressSpec;
this.wantsDryRun = wantsDryRun;
}
public ExecutionResult apply(List<Cmd> cmds) {
@@ -71,6 +71,8 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
logger.info("No commands provided.");
}
Map<String, String> params = new CmdParamsBuffer(cmds).getGlobalParams();
ResultCollector collector = new ResultCollector();
try (ResultContext results = new ResultContext(collector)) {
@@ -78,13 +80,13 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
NBScenario scenario;
if (cmds.get(0).getCmdType().equals(Cmd.CmdType.java)) {
scenario = buildJavaScenario(cmds, wantsDryRun);
scenario = buildJavaScenario(cmds);
} else {
scenario = buildJavacriptScenario(cmds, wantsDryRun);
scenario = buildJavacriptScenario(cmds);
}
try (NBComponentSubScope scope = new NBComponentSubScope(scenario)) {
assert scenario != null;
scenariosExecutor.execute(scenario);
scenariosExecutor.execute(scenario,params);
// this.doReportSummaries(this.reportSummaryTo, this.result);
}
@@ -106,16 +108,18 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
}
results.output(scenariosResults.getExecutionSummary());
results.ok();
}
return collector.toExecutionResult();
}
private NBScenario buildJavacriptScenario(List<Cmd> cmds, boolean dryrun) {
NBScriptedScenario.Invocation invocation = dryrun ?
NBScriptedScenario.Invocation.RENDER_SCRIPT :
NBScriptedScenario.Invocation.EXECUTE_SCRIPT;
private NBScenario buildJavacriptScenario(List<Cmd> cmds) {
// boolean dryrun;
// NBScriptedScenario.Invocation invocation = dryrun ?
// NBScriptedScenario.Invocation.RENDER_SCRIPT :
// NBScriptedScenario.Invocation.EXECUTE_SCRIPT;
final ScriptBuffer buffer = new BasicScriptBuffer().add(cmds.toArray(new Cmd[0]));
final String scriptData = buffer.getParsedScript();
@@ -123,21 +127,35 @@ public class NBSession extends NBBaseComponent implements Function<List<Cmd>, Ex
final ScriptParams scriptParams = new ScriptParams();
scriptParams.putAll(buffer.getCombinedParams());
final NBScriptedScenario scenario = new NBScriptedScenario(
sessionName,
progressSpec,
scriptParams,
this,
invocation
);
final NBScriptedScenario scenario = new NBScriptedScenario(sessionName, this);
scenario.addScriptText(scriptData);
scenario.addScenarioScriptParams(scriptParams);
return scenario;
}
private NBScenario buildJavaScenario(List<Cmd> cmds, boolean dryrun) {
return null;
private NBScenario buildJavaScenario(List<Cmd> cmds) {
if (cmds.size()!=1) {
throw new RuntimeException("java scenarios require exactly 1 java command");
}
Cmd javacmd = cmds.get(0);
String mainClass = javacmd.getArg("main_class");
SimpleServiceLoader<NBScenario> loader = new SimpleServiceLoader<>(NBScenario.class, Maturity.Any);
List<SimpleServiceLoader.Component<? extends NBScenario>> namedProviders = loader.getNamedProviders(mainClass);
SimpleServiceLoader.Component<? extends NBScenario> provider = namedProviders.get(0);
Class<? extends NBScenario> type = provider.provider.type();
try {
Constructor<? extends NBScenario> constructor = type.getConstructor(NBComponent.class, String.class);
NBScenario scenario = constructor.newInstance(this, sessionName);
return scenario;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -268,14 +268,14 @@ public class ActivityMetrics {
public static NBMetricGauge gauge(NBMetricGauge gauge) {
final NBLabels labels = gauge.getLabels();
return (NBMetricGauge) register(labels, () -> new NBMetricGaugeWrapper<>(labels, gauge));
return (NBMetricGauge) register(labels, () -> new NBMetricGaugeWrapper(labels, gauge));
}
@SuppressWarnings("unchecked")
public static <T> Gauge<T> gauge(NBLabeledElement parent, String metricFamilyName, Gauge<T> gauge) {
public static Gauge<Double> gauge(NBLabeledElement parent, String metricFamilyName, Gauge<Double> gauge) {
final NBLabels labels = parent.getLabels().and("name", sanitize(metricFamilyName));
return (Gauge<T>) register(labels, () -> new NBMetricGaugeWrapper<>(labels, gauge));
return (Gauge<Double>) register(labels, () -> new NBMetricGaugeWrapper(labels, gauge));
}
private static MetricRegistry lookupRegistry() {

View File

@@ -26,7 +26,7 @@ import java.util.function.DoubleConsumer;
/**
* Create a discrete stat reservoir as a gauge.
*/
public class DoubleSummaryGauge implements NBMetricGauge<Double>, DoubleConsumer {
public class DoubleSummaryGauge implements NBMetricGauge, DoubleConsumer {
private final NBLabels labels;
private final Stat stat;
private final DoubleSummaryStatistics stats;

View File

@@ -23,7 +23,7 @@ import io.nosqlbench.components.NBComponent;
import java.util.Map;
import java.util.function.Supplier;
public class NBFunctionGauge implements NBMetricGauge<Double> {
public class NBFunctionGauge implements NBMetricGauge {
private final Supplier<Double> source;
private final NBLabeledElement parent;

View File

@@ -18,6 +18,6 @@ package io.nosqlbench.api.engine.metrics.instruments;
import com.codahale.metrics.Gauge;
public interface NBMetricGauge<T> extends Gauge<T>, NBMetric {
public interface NBMetricGauge extends Gauge<Double>, NBMetric {
}

View File

@@ -19,18 +19,18 @@ package io.nosqlbench.api.engine.metrics.instruments;
import com.codahale.metrics.Gauge;
import io.nosqlbench.api.labels.NBLabels;
public class NBMetricGaugeWrapper<T> implements NBMetricGauge<T>, NBMetric {
public class NBMetricGaugeWrapper implements NBMetricGauge, NBMetric {
private final Gauge<? extends T> gauge;
private final Gauge<Double> gauge;
private final NBLabels labels;
public NBMetricGaugeWrapper(NBLabels labels, Gauge<? extends T> gauge) {
public NBMetricGaugeWrapper(NBLabels labels, Gauge<Double> gauge) {
this.gauge = gauge;
this.labels = labels;
}
@Override
public T getValue() {
public Double getValue() {
return gauge.getValue();
}

View File

@@ -32,17 +32,19 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
private final NBLabels labels;
public NBBaseComponent(NBComponent parentComponent) {
this(parentComponent,NBLabels.forKV());
this(parentComponent, NBLabels.forKV());
}
public NBBaseComponent(NBComponent parentComponent, NBLabels componentSpecificLabelsOnly) {
this.labels = componentSpecificLabelsOnly;
if (parentComponent!=null) {
if (parentComponent != null) {
parent = parentComponent;
parent.attachChild(this);
} else {
parent=null;
parent = null;
}
}
@Override
public NBComponent getParent() {
return parent;
@@ -74,7 +76,7 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
@Override
public NBLabels getLabels() {
return (this.parent==null) ? labels : this.parent.getLabels().and(labels);
return (this.parent == null) ? labels : this.parent.getLabels().and(labels);
}
@Override
@@ -83,7 +85,7 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
while (tree.hasNext()) {
NBComponent c = tree.next();
NBMetric metric = c.lookupMetric(name);
if (metric!=null) return metric;
if (metric != null) return metric;
}
return null;
}
@@ -99,6 +101,17 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
return found;
}
@Override
public NBMetric findOneMetricInTree(String pattern) {
List<NBMetric> found = findMetricsInTree(pattern);
if (found.size() != 1) {
System.out.println("Runtime Components and Metrics at this time:\n"+NBComponentFormats.formatAsTree(this));
throw new RuntimeException("Found " + found.size() + " metrics with pattern '" + pattern + "', expected exactly 1");
}
return found.get(0);
}
@Override
public void beforeDetach() {
logger.debug("before detach " + description());
@@ -117,7 +130,7 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
logger.error(e);
} finally {
logger.debug("detaching " + description());
if (parent!=null) {
if (parent != null) {
parent.detachChild(this);
}
}

View File

@@ -0,0 +1,27 @@
package io.nosqlbench.components;
import java.util.Iterator;
public class NBComponentFormats {
public static String formatAsTree(NBBaseComponent base) {
StringBuilder sb = new StringBuilder();
PrintVisitor pv = new PrintVisitor(sb);
NBComponentTraversal.visitDepthFirst(base,pv);
return sb.toString();
}
private final static class PrintVisitor implements NBComponentTraversal.Visitor {
private final StringBuilder builder;
public PrintVisitor(StringBuilder sb) {
this.builder = sb;
}
@Override
public void visit(NBComponent component, int depth) {
builder.append(String.format("%03d %s\n",depth,component));
}
}
}

View File

@@ -18,6 +18,7 @@ package io.nosqlbench.components;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class NBComponentTraversal {
@@ -25,6 +26,17 @@ public class NBComponentTraversal {
return new iterDepthFirst(component);
}
public static void visitDepthFirst(NBComponent component, Visitor visitor) {
visitDepthFirst(component,visitor,0);
}
private static void visitDepthFirst(NBComponent component, Visitor visitor, int depth) {
visitor.visit(component,depth);
List<NBComponent> children = component.getChildren();
for (NBComponent child : children) {
visitDepthFirst(child,visitor,depth+1);
}
}
public static Iterator<NBComponent> traverseBreadth(NBComponent component) {
return new IterBreadthFirst(component);
}
@@ -71,4 +83,7 @@ public class NBComponentTraversal {
}
}
public interface Visitor {
void visit(NBComponent component, int depth);
}
}

View File

@@ -17,6 +17,8 @@
package io.nosqlbench.components;
import io.nosqlbench.api.engine.metrics.instruments.NBMetric;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricCounter;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricGauge;
public class NBFinders {
private final NBBaseComponent base;
@@ -31,6 +33,32 @@ public class NBFinders {
metric = base.findOneMetricInTree(pattern);
return metric;
}
private <T extends NBMetric> T findOneMetricWithType(String pattern, Class<T> clazz) {
NBMetric found = metric(pattern);
if (found==null) {
System.out.println(NBComponentFormats.formatAsTree(base));
throw new RuntimeException("unable to find metric with pattern '" + pattern + "'");
}
if (clazz.isAssignableFrom(found.getClass())) {
return clazz.cast(found);
} else {
throw new RuntimeException(
"found metric with pattern '" + pattern + "'" +
", but it was type "
+ found.getClass().getSimpleName() + " (not a "
+ clazz.getSimpleName() +")"
);
}
}
public NBMetricGauge metricGauge(String pattern) {
return findOneMetricWithType(pattern, NBMetricGauge.class);
}
public NBMetricCounter metricCounter(String pattern) {
return findOneMetricWithType(pattern, NBMetricCounter.class);
}
}

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Optional;
public interface NBMetricsQuery {
/**
* If you have the serialized open metrics name of a metric, you can ask for it
* this way and get a direct result.
@@ -36,12 +37,6 @@ public interface NBMetricsQuery {
List<NBMetric> findMetricsInTree(String pattern);
default NBMetric findOneMetricInTree(String pattern) {
List<NBMetric> found = findMetricsInTree(pattern);
if (found.size()!=1) {
throw new RuntimeException("Found " + found.size() + " metrics with pattern '" + pattern + "', expected exactly 1");
}
return found.get(0);
}
NBMetric findOneMetricInTree(String pattern);
}

View File

@@ -58,4 +58,13 @@ class NBComponentTraversalTest {
assertThat(wider).containsExactly(a,sub1,sub2,dotX,dotY);
}
@Test
public void testDepthFirstVisitor() {
NBComponentTraversal.visitDepthFirst(a, new NBComponentTraversal.Visitor() {
@Override
public void visit(NBComponent component, int depth) {
System.out.println(">".repeat(depth)+":"+component.description());
}
});
}
}

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<Configuration status="debug" strict="true" name="XMLConfigTest">
<Filter type="ThresholdFilter" level="trace"/>
<Appenders>
<Appender type="Console" name="STDOUT">
<Layout type="PatternLayout" pattern="%7r %-5level [%t] %-12logger{0} %msg%n%throwable"/>
<Filters>
<Filter type="MarkerFilter" marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
<Filter type="MarkerFilter" marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
</Filters>
</Appender>
<Appender type="Console" name="FLOW">
<Layout type="PatternLayout" pattern="%C{1}.%M %m %ex%n"/><!-- class and line number -->
<Filters>
<Filter type="MarkerFilter" marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<Filter type="MarkerFilter" marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</Appender>
<Appender type="File" name="APPSLOG" fileName="docs/apps.log">
<Layout type="PatternLayout">
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</Layout>
</Appender>
</Appenders>
<Loggers>
<Logger name="io.nosqlbench.docsys" level="info" additivity="false">
<AppenderRef ref="APPSLOG"/>
</Logger>
<Root level="trace">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>

View File

@@ -1,38 +0,0 @@
/*
* 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.nbr;
import io.nosqlbench.api.config.standard.TestComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosExecutor;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosResults;
import io.nosqlbench.nbr.examples.SCDryRunScenarioTest;
import org.junit.jupiter.api.Test;
import java.util.Map;
public class DirectRuntimeScenarioTests {
@Test
public void testDirect() {
TestComponent testC = new TestComponent("testroot", "testroot");
SCDryRunScenarioTest sc1 = new SCDryRunScenarioTest(TestComponent.EMPTY_COMPONENT, "test", Map.of(), "console:1s");
ScenariosExecutor executor = new ScenariosExecutor(TestComponent.EMPTY_COMPONENT, "test", 1);
executor.execute(sc1);
ScenariosResults results = executor.awaitAllResults();
System.out.println(results);
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.nbr.examples;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.context.ActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneFixtures;
import io.nosqlbench.engine.core.lifecycle.scenario.context.ScriptParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
public abstract class SCBaseScenario extends NBScenario {
protected NBComponent component;
protected Reader stdin;
protected PrintWriter stdout;
protected Writer stderr;
protected ActivitiesController controller;
protected ScriptParams params;
public SCBaseScenario(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
@Override
protected void runScenario(NBSceneFixtures shell) {
this.component = shell.component();
this.stdin = shell.in();
this.stdout = shell.out();
this.stderr = shell.err();
this.controller = shell.controller();
this.params = shell.params();
invoke();
}
public abstract void invoke();
}

View File

@@ -1,80 +0,0 @@
/*
* 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.nbr.examples;
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneFixtures;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import java.util.Map;
public class SCDryRunScenarioTest extends NBScenario {
public SCDryRunScenarioTest(NBComponent parentComponent, String scenarioName, Map<String, String> params, String progressInterval) {
super(parentComponent, scenarioName, params, progressInterval);
}
/**
* print('starting activity activity_error');
* scenario.start(activitydef1);
* scenario.waitMillis(2000);
* activities.activity_error.threads = "unparsable";
* scenario.awaitActivity("activity_error");
* print("awaited activity");
*/
@Override
protected void runScenario(NBSceneFixtures shell) {
/**
* activitydef1 = {
* "alias": "activity_error",
* "driver": "diag",
* "cycles": "0..1500000",
* "threads": "1",
* "targetrate": "10",
* "op": "log: modulo=1"
* };
*/
var activitydef1 = Map.of("alias", "activity_error",
"driver", "diag",
"cycles", "0..1500000",
"threads", "1",
"targetrate", "10",
"op", "log: modulo=1");
// print('starting activity activity_error');
shell.out().write("starting activity activity_error");
// scenario.start(activitydef1);
shell.controller().start(activitydef1);
// scenario.waitMillis(2000);
shell.controller().waitMillis(2000);
// activities.activity_error.threads = "unparsable";
ActivityDef def = shell.controller().getActivityDef("activity_error");
def.getParams().set("threads","unparsable");
// scenario.awaitActivity("activity_error");
shell.controller().awaitActivity("activity_error", Long.MAX_VALUE);
// print("awaited activity");
shell.out().println("awaited activity");
}
}

View File

@@ -61,7 +61,7 @@ public class ScriptExampleTests {
ScenariosExecutor executor = new ScenariosExecutor(new TestComponent("test","test"),ScriptExampleTests.class.getSimpleName() + ":" + scriptname, 1);
NBScriptedScenario s = NBScriptedScenario.ofScripted(scenarioName,Map.of(),new TestComponent("test","test"), NBScriptedScenario.Invocation.EXECUTE_SCRIPT);
s.addScenarioScriptParams(paramsMap);
// s.addScenarioScriptParams(paramsMap);
ClassLoader cl = ScriptExampleTests.class.getClassLoader();
String script;
@@ -78,7 +78,7 @@ public class ScriptExampleTests {
}
s.addScriptText(script);
// s.addScriptText("load('classpath:scripts/async/" + scriptname + ".js');");
executor.execute(s);
executor.execute(s,paramsMap);
ScenariosResults scenariosResults = executor.awaitAllResults();
ScenarioResult scenarioResult = scenariosResults.getOne();
executor.shutdownNow();

View File

@@ -0,0 +1,12 @@
# Scenario Invocation
```mermaid
flowchart LR
IO\nbuffers -. "embed" .-> fixtures
params --> fixtures
fixtures --> Scenario\ninstance
Scenario\ninstance --> used\nfixtures
used\nfixtures -. extract .-> IO\ntraces
```

View File

@@ -0,0 +1,163 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.api.config.standard.TestComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneBuffer;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenarioResult;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosExecutor;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.ScenariosResults;
import io.nosqlbench.nbr.examples.injava.*;
import org.junit.jupiter.api.Test;
public class DirectRuntimeScenarioTests {
private final TestComponent testC = new TestComponent("testroot", "testroot");
@Test
public void testDirect() {
TestComponent testC = new TestComponent("testroot", "testroot");
SC_activity_error sc1 = new SC_activity_error(TestComponent.EMPTY_COMPONENT, "test");
ScenariosExecutor executor = new ScenariosExecutor(TestComponent.EMPTY_COMPONENT, "test", 1);
executor.execute(sc1);
ScenariosResults results = executor.awaitAllResults();
System.out.println(results);
}
@Test
public void testSC_activit_init_error() {
SC_start_stop_diag scenario = new SC_start_stop_diag(testC, "SC_start_stop_diag");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("SC_start_stop_diag"));
}
@Test
public void test_SC_activity_error() {
NBScenario scenario = new SC_activity_error(testC,"test_SC_activity_error");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_activity_error"));
}
@Test
public void test_SC_activity_init_error() {
NBScenario scenario = new SC_activity_init_error(testC,"test_SC_activity_init_error");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_activity_init_error"));
}
@Test
public void test_SC_await_finished() {
NBScenario scenario = new SC_await_finished(testC,"test_SC_await_finished");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_await_finished"));
}
@Test
public void test_SC_basicdiag() {
NBScenario scenario = new SC_basicdiag(testC,"test_SC_basicdiag");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_basicdiag"));
}
@Test
public void test_SC_blockingrun() {
NBScenario scenario = new SC_blockingrun(testC,"test_SC_blockingrun");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_blockingrun"));
}
@Test
public void test_SC_cocycledelay_bursty() {
NBScenario scenario = new SC_cocycledelay_bursty(testC,"test_SC_cocycledelay_bursty");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_cocycledelay_bursty"));
result.report();
}
@Test
public void test_SC_cocycledelay_strict() {
NBScenario scenario = new SC_cocycledelay_strict(testC,"test_SC_cocycledelay_strict");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_cocycledelay_strict"));
}
@Test
public void test_SC_cycle_rate() {
NBScenario scenario = new SC_cycle_rate(testC,"test_SC_cycle_rate");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_cycle_rate"));
}
@Test
public void test_SC_cycle_rate_change() {
NBScenario scenario = new SC_cycle_rate_change(testC,"test_SC_cycle_rate_change");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_cycle_rate_change"));
}
@Test
public void test_SC_extension_csvmetrics() {
NBScenario scenario = new SC_extension_csvmetrics(testC,"test_SC_extension_csvmetrics");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_extension_csvmetrics"));
}
@Test
public void test_SC_extension_csvoutput() {
NBScenario scenario = new SC_extension_csvoutput(testC,"test_SC_extension_csvoutput");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_extension_csvoutput"));
}
@Test
public void test_SC_extension_histostatslogger() {
NBScenario scenario = new SC_extension_histostatslogger(testC,"test_SC_extension_histostatslogger");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_extension_histostatslogger"));
}
@Test
public void test_SC_extension_shutdown_hook() {
NBScenario scenario = new SC_extension_shutdown_hook(testC,"test_SC_extension_shutdown_hook");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_extension_shutdown_hook"));
}
@Test
public void test_SC_histologger() {
NBScenario scenario = new SC_histologger(testC,"test_SC_histologger");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_histologger"));
}
@Test
public void test_SC_linkedinput() {
NBScenario scenario = new SC_linkedinput(testC,"test_SC_linkedinput");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_linkedinput"));
}
@Test
public void test_SC_optimo() {
NBScenario scenario = new SC_optimo(testC,"test_SC_optimo");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_optimo"));
}
@Test
public void test_SC_params_variable() {
NBScenario scenario = new SC_params_variable(testC,"test_SC_params_variable");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_params_variable"));
}
@Test
public void test_SC_readmetrics() {
NBScenario scenario = new SC_readmetrics(testC,"test_SC_readmetrics");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_readmetrics"));
}
@Test
public void test_SC_speedcheck() {
NBScenario scenario = new SC_speedcheck(testC,"test_SC_speedcheck");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_speedcheck"));
}
@Test
public void test_SC_start_stop_diag() {
NBScenario scenario = new SC_start_stop_diag(testC,"test_SC_start_stop_diag");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_start_stop_diag"));
}
@Test
public void test_SC_threadchange() {
NBScenario scenario = new SC_threadchange(testC,"test_SC_threadchange");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_threadchange"));
}
@Test
public void test_SC_threadspeeds() {
NBScenario scenario = new SC_threadspeeds(testC,"test_SC_threadspeeds");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_threadspeeds"));
}
@Test
public void test_SC_undef_param() {
NBScenario scenario = new SC_undef_param(testC, "test_SC_undef_param");
ScenarioResult result = scenario.apply(NBSceneBuffer.init("test_SC_undef_param"));
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.context.NBSceneFixtures;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_activity_error extends SCBaseScenario {
public SC_activity_error(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
@Override
protected void runScenario(NBSceneFixtures shell) {
// HdrHistoLogPluginData hdrHistoLogPluginData = new HdrHistoLogPluginData();
// HdrHistoLogPlugin histologplugin = hdrHistoLogPluginData.getExtensionObject(...);
// histologplugin.logHistoIntervals(...);
// HdrHistoLogPlugin logplugin = shell.extensions().get("histologger",HdrHistoLogPlugin.class);
// var serviceojbect = extensions.get("histologger");
// AttachedMetricsSummaryReporter reporter = shell.runtime().create().summaryReporter(5, "labelname", "labelvalue");
}
/**
* Equivalent to javascript form:
* <pre>{@code
* activitydef1 = {
* "alias": "activity_error",
* "driver": "diag",
* "cycles": "0..1500000",
* "threads": "1",
* "targetrate": "10",
* "op": "log: modulo=1"
* };
*
* print('starting activity activity_error');
* scenario.start(activitydef1);
* scenario.waitMillis(2000);
* activities.activity_error.threads = "unparsable";
* scenario.awaitActivity("activity_error");
* print("awaited activity");
* </pre>
*/
@Override
public void invoke() {
var activitydef1 = Map.of("alias", "activity_error",
"driver", "diag",
"cycles", "0..1500000",
"threads", "1",
"targetrate", "10",
"op", "log: modulo=1"
);
stdout.write("starting activity activity_error");
controller.start(activitydef1);
controller.waitMillis(2000);
controller.getActivityDef("activity_error").getParams().set("threads","unparsable"); // forced error
controller.awaitActivity("activity_error", Long.MAX_VALUE);
}
}

View File

@@ -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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBScenario;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
@Service(value=NBScenario.class,selector="activity_init_error")
public class SC_activity_init_error extends SCBaseScenario {
public SC_activity_init_error(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef1 = {
* "alias" : "activity_init_error",
* "driver" : "diag",
* "cycles" : "invalid",
* "threads" : "1",
* "targetrate" : "500",
* "unknown_config" : "unparsable",
* "op" : "noop"
* };
*
* print('starting activity activity_init_error');
* scenario.start(activitydef1);
* scenario.waitMillis(2000);
* scenario.awaitActivity("activity_init_error");
* print("awaited activity");}</pre>
*
*/
@Override
public void invoke() {
var activitydef1 = Map.of(
"alias","activity_init_error",
"driver","diag",
"cycles","invalid",
"threads","1",
"targetrate","500",
"unknown_config","unparsable",
"op","noop"
);
stdout.println("starting activity activity_init_error");
controller.start(activitydef1);
controller.waitMillis(2000);
controller.awaitActivity("activity_init_error",Long.MAX_VALUE);
stdout.println("awaited activity");
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.engine.cli.Cmd;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_await_finished extends SCBaseScenario {
public SC_await_finished(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/**
* <pre>{@code
* activitydef1 = {
* "alias" : "activity_to_await",
* "driver" : "diag",
* "cycles" : "0..1500",
* "threads" : "1",
* "targetrate" : "500",
* "op" : "noop"
* };
*
* print('starting activity teststartstopdiag');
* scenario.start(activitydef1);
* scenario.awaitActivity("activity_to_await");
* print("awaited activity");
* }</pre>
*/
@Override
public void invoke() {
var activitydef1 = Map.of(
"alias", "activity_to_await",
"driver", "diag",
"cycles", "0..1500",
"threads", "1",
"targetrate", "500",
"op", "noop"
);
stdout.println("starting activity activity_to_await");
controller.start(activitydef1);
controller.awaitActivity("activity_to_await",1000L);
stdout.println("awaited activity");
}
}

View File

@@ -0,0 +1,48 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_basicdiag extends SCBaseScenario {
public SC_basicdiag(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* basic_diag = params.withOverrides({
* "alias" : "basic_diag",
* "driver" : "diag"
* });
*
*
* print('starting activity basic_diag');
* scenario.start(basic_diag);
* }</pre>
*/
@Override
public void invoke() {
var basic_diag = params.withOverrides(
Map.of("alias","basic_diag","driver","diag")
);
stdout.println("starting activity basic_diag");
controller.start(basic_diag);
}
}

View File

@@ -0,0 +1,77 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_blockingrun extends SCBaseScenario {
public SC_blockingrun(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef1 = {
* "alias" : "blockingactivity1",
* "driver" : "diag",
* "cycles" : "0..100000",
* "threads" : "1",
* "interval" : "2000",
* "op":"noop"
* };
* activitydef2 = {
* "alias" : "blockingactivity2",
* "driver" : "diag",
* "cycles" : "0..100000",
* "threads" : "1",
* "interval" : "2000",
* "op":"noop"
* };
*
*
* print('running blockingactivity1');
* scenario.run(10000,activitydef1);
* print('blockingactivity1 finished');
* print('running blockingactivity2');
* scenario.run(10000,activitydef2);
* print('blockingactivity2 finished');
* }</pre>
*/
@Override
public void invoke() {
var activitydef1 = Map.of(
"alias","blockactivity1","driver","diag",
"cycles","0..100000","threads","1",
"interval","2000","op","noop"
);
var activitydef2 = Map.of(
"alias", "blockingactivity2","driver","diag",
"cycles","0..100000","threads","1",
"interval","2000", "op","noop"
);
stdout.println("running blockingactivity1");
controller.run(activitydef1);
stdout.println("blockingactivity1 finished");
stdout.println("running blockingactivity2");
controller.run(activitydef2);
stdout.println("blockingactivity2 finished");
}
}

View File

@@ -0,0 +1,148 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricCounter;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricGauge;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_cocycledelay_bursty extends SCBaseScenario {
public SC_cocycledelay_bursty(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/**
* <pre>{@code
* co_cycle_delay_bursty = {
* "alias": "co_cycle_delay_bursty",
* "driver": "diag",
* "cycles": "0..1000000",
* "threads": "10",
* "cyclerate": "1000,1.5",
* "op" : "diagrate: diagrate=500"
* };
*
* print('starting activity co_cycle_delay_bursty');
* scenario.start(co_cycle_delay_bursty);
* for (i = 0; i < 5; i++) {
* scenario.waitMillis(1000);
* if (!scenario.isRunningActivity('co_cycle_delay_bursty')) {
* print("scenario exited prematurely, aborting.");
* break;
* }
* print("backlogging, cycles=" + metrics.co_cycle_delay_bursty.cycles_servicetime.count +
* " waittime=" + metrics.co_cycle_delay_bursty.cycles_waittime.value +
* " diagrate=" + activities.co_cycle_delay_bursty.diagrate +
* " cyclerate=" + activities.co_cycle_delay_bursty.cyclerate
* );
* }
* print('step1 metrics.waittime=' + metrics.co_cycle_delay_bursty.cycles_waittime.value);
* activities.co_cycle_delay_bursty.diagrate = "10000";
*
* for (i = 0; i < 10; i++) {
* if (!scenario.isRunningActivity('co_cycle_delay_bursty')) {
* print("scenario exited prematurely, aborting.");
* break;
* }
* print("recovering, cycles=" + metrics.co_cycle_delay_bursty.cycles_servicetime.count +
* " waittime=" + metrics.co_cycle_delay_bursty.cycles_waittime.value +
* " diagrate=" + activities.co_cycle_delay_bursty.diagrate +
* " cyclerate=" + activities.co_cycle_delay_bursty.cyclerate
* );
*
* scenario.waitMillis(1000);
* if (metrics.co_cycle_delay_bursty.cycles_waittime.value < 50000000) {
* print("waittime trended back down as expected, exiting on iteration " + i);
* break;
* }
* }
* //scenario.awaitActivity("co_cycle_delay");
* print('step2 metrics.waittime=' + metrics.co_cycle_delay_bursty.cycles_waittime.value);
* scenario.stop(co_cycle_delay_bursty);
* print("stopped activity co_cycle_delay_bursty");
* }</pre>
*/
@Override
public void invoke() {
var co_cycle_delay_bursty = Map.of(
"alias", "co_cycle_delay_bursty",
"driver", "diag",
"cycles", "0..1000000",
"threads", "1",
"cyclerate", "10,1.5",
"op", "log: level=info"
);
controller.waitMillis(1000);
stdout.println("starting activity co_cycle_delay_bursty");
controller.start(co_cycle_delay_bursty);
NBMetricCounter service_time_counter = find().metricCounter("activity=co_cycle_delay_bursty,name=cycles_servicetime");
NBMetricGauge wait_time_gauge = find().metricGauge("activity=co_cycle_delay_bursty,name=cycles_waittime");
String diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
String cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
//
// for (int i = 0; i < 5; i++) {
// controller.waitMillis(1000);
// if (!controller.isRunningActivity(co_cycle_delay_bursty)) {
// stdout.println("scenario exited prematurely, aborting.");
// break;
// }
// diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
// cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
// stdout.println(
// "backlogging, cycles=" + service_time_counter.getCount() +
// " waittime=" + wait_time_gauge.getValue() +
// " diagrate=" + diagrate +
// " cyclerate=" + cyclerate
// );
// }
//
// stdout.println("step1 metrics.waittime=" + wait_time_gauge.getValue());
// controller.getActivityDef("co_cycle_delay_bursty").getParams().put("diagrate", "10000");
//
// for (int i = 0; i < 10; i++) {
// if (!controller.isRunningActivity("co_cycle_delay_bursty")) {
// stdout.println("scenario exited prematurely, aborting.");
// break;
// }
// diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
// cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
//
// stdout.println(
// "recovering, cycles=" + service_time_counter.getCount() +
// " waittime=" + wait_time_gauge.getValue() +
// " diagrate=" + diagrate +
// " cyclerate=" + cyclerate
// );
//
// controller.waitMillis(1000);
// if (wait_time_gauge.getValue() < 50000000) {
// stdout.println("waittime trended back down as expected, exiting on iteration " + i);
// break;
// }
// }
//
// stdout.println("step2 metrics.waittime=" + wait_time_gauge.getValue());
// controller.stop(co_cycle_delay_bursty);
//
// stdout.println("stopped activity co_cycle_delay_bursty");
}
}

View File

@@ -0,0 +1,150 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricCounter;
import io.nosqlbench.api.engine.metrics.instruments.NBMetricGauge;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_cocycledelay_bursty_backup extends SCBaseScenario {
public SC_cocycledelay_bursty_backup(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/**
* <pre>{@code
* co_cycle_delay_bursty = {
* "alias": "co_cycle_delay_bursty",
* "driver": "diag",
* "cycles": "0..1000000",
* "threads": "10",
* "cyclerate": "1000,1.5",
* "op" : "diagrate: diagrate=500"
* };
*
* print('starting activity co_cycle_delay_bursty');
* scenario.start(co_cycle_delay_bursty);
* for (i = 0; i < 5; i++) {
* scenario.waitMillis(1000);
* if (!scenario.isRunningActivity('co_cycle_delay_bursty')) {
* print("scenario exited prematurely, aborting.");
* break;
* }
* print("backlogging, cycles=" + metrics.co_cycle_delay_bursty.cycles_servicetime.count +
* " waittime=" + metrics.co_cycle_delay_bursty.cycles_waittime.value +
* " diagrate=" + activities.co_cycle_delay_bursty.diagrate +
* " cyclerate=" + activities.co_cycle_delay_bursty.cyclerate
* );
* }
* print('step1 metrics.waittime=' + metrics.co_cycle_delay_bursty.cycles_waittime.value);
* activities.co_cycle_delay_bursty.diagrate = "10000";
*
* for (i = 0; i < 10; i++) {
* if (!scenario.isRunningActivity('co_cycle_delay_bursty')) {
* print("scenario exited prematurely, aborting.");
* break;
* }
* print("recovering, cycles=" + metrics.co_cycle_delay_bursty.cycles_servicetime.count +
* " waittime=" + metrics.co_cycle_delay_bursty.cycles_waittime.value +
* " diagrate=" + activities.co_cycle_delay_bursty.diagrate +
* " cyclerate=" + activities.co_cycle_delay_bursty.cyclerate
* );
*
* scenario.waitMillis(1000);
* if (metrics.co_cycle_delay_bursty.cycles_waittime.value < 50000000) {
* print("waittime trended back down as expected, exiting on iteration " + i);
* break;
* }
* }
* //scenario.awaitActivity("co_cycle_delay");
* print('step2 metrics.waittime=' + metrics.co_cycle_delay_bursty.cycles_waittime.value);
* scenario.stop(co_cycle_delay_bursty);
* print("stopped activity co_cycle_delay_bursty");
* }</pre>
*/
@Override
public void invoke() {
var co_cycle_delay_bursty = Map.of(
"alias", "co_cycle_delay_bursty",
"driver", "diag",
"cycles", "0..1000000",
"threads", "1",
"cyclerate", "1000,1.5",
"op", "diagrate: diagrate=500"
);
stdout.println("starting activity co_cycle_delay_bursty");
controller.start(co_cycle_delay_bursty);
NBMetricCounter service_time_counter = find().metricCounter("activity=co_cycle_delay_bursty,name=cycles_servicetime");
NBMetricGauge wait_time_gauge = find().metricGauge("activity=co_cycle_delay_bursty,name=cycles_waittime");
String diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
String cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
for (int i = 0; i < 5; i++) {
controller.waitMillis(1000);
if (!controller.isRunningActivity(co_cycle_delay_bursty)) {
stdout.println("scenario exited prematurely, aborting.");
break;
}
diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
stdout.println(
"backlogging, cycles=" + service_time_counter.getCount() +
" waittime=" + wait_time_gauge.getValue() +
" diagrate=" + diagrate +
" cyclerate=" + cyclerate
);
}
stdout.println("step1 metrics.waittime=" + wait_time_gauge.getValue());
controller.getActivityDef("co_cycle_delay_bursty").getParams().put("diagrate", "10000");
for (int i = 0; i < 10; i++) {
if (!controller.isRunningActivity("co_cycle_delay_bursty")) {
stdout.println("scenario exited prematurely, aborting.");
break;
}
diagrate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("diagrate").toString();
cyclerate = controller.getActivityDef("co_cycle_delay_bursty").getParams().get("cyclerate").toString();
stdout.println(
"recovering, cycles=" + service_time_counter.getCount() +
" waittime=" + wait_time_gauge.getValue() +
" diagrate=" + diagrate +
" cyclerate=" + cyclerate
);
controller.waitMillis(1000);
if (wait_time_gauge.getValue() < 50000000) {
stdout.println("waittime trended back down as expected, exiting on iteration " + i);
break;
}
}
stdout.println("step2 metrics.waittime=" + wait_time_gauge.getValue());
controller.stop(co_cycle_delay_bursty);
stdout.println("stopped activity co_cycle_delay_bursty");
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_cocycledelay_strict extends SCBaseScenario {
public SC_cocycledelay_strict(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* co_cycle_delay = {
* "alias" : "co_cycle_delay",
* "driver" : "diag",
* "cycles" : "0..10000",
* "threads" : "1",
* "cyclerate" : "1000,1.0",
* "op" : "diagrate:diagrate=800"
* };
*
* print('starting activity co_cycle_delay');
* scenario.start(co_cycle_delay);
* scenario.waitMillis(4000);
* print('step1 cycles_waittime=' + metrics.co_cycle_delay.cycles_waittime.value);
* activities.co_cycle_delay.diagrate="10000";
* for(i=0;i<5;i++) {
* if (! scenario.isRunningActivity('co_cycle_delay')) {
* print("scenario exited prematurely, aborting.");
* break;
* }
* print("iteration " + i + " waittime now " + metrics.co_cycle_delay.cycles_waittime.value);
* scenario.waitMillis(1000);
* }
*
*
* //scenario.awaitActivity("co_cycle_delay");
* print('step2 cycles_waittime=' + metrics.co_cycle_delay.cycles_waittime.value);
* print("awaited activity");
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_cycle_rate extends SCBaseScenario {
public SC_cycle_rate(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "cycle_rate",
* "driver" : "diag",
* "cycles" : "2500",
* "threads" : "10",
* "cyclerate" : "500",
* "op" : "noop"
* };
*
* scenario.run(activitydef);
*
* print("current cycle = " + metrics.cycle_rate.cycles_servicetime.count);
* print("mean cycle rate = " + metrics.cycle_rate.cycles_servicetime.meanRate);
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_cycle_rate_change extends SCBaseScenario {
public SC_cycle_rate_change(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "cycle_rate_change",
* "driver" : "diag",
* "cycles" : "0..1000000",
* "threads" : "10",
* "cyclerate" : "2000",
* "interval" : "2000",
* "op" : "noop"
* };
*
* print('starting cycle_rate_change');
* scenario.start(activitydef);
* print('started');
* print('cyclerate at 0ms:' + activities.cycle_rate_change.cyclerate);
* scenario.waitMillis(500);
* activities.cycle_rate_change.cyclerate='1000';
* print("measured cycle increment per second is expected to adjust to 1000");
*
* print('cyclerate now:' + activities.cycle_rate_change.cyclerate);
*
* var lastcount=metrics.cycle_rate_change.cycles_servicetime.count;
* for(i=0;i<20;i++) {
* scenario.waitMillis(1000);
* var nextcount=metrics.cycle_rate_change.cycles_servicetime.count;
* var cycles = (nextcount - lastcount);
* print("new this second: " + (nextcount - lastcount));
* print(" waittime: " + metrics.cycle_rate_change.cycles_waittime.value);
* lastcount=nextcount;
* if (cycles>700 && cycles<1300) {
* print("cycles adjusted, exiting on iteration " + i);
* break;
* }
* }
* scenario.stop(activitydef);
* print('cycle_rate_change activity finished');
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_extension_csvmetrics extends SCBaseScenario {
public SC_extension_csvmetrics(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* var csvlogger = csvmetrics.log("logs/csvmetricstestdir");
*
* activitydef = {
* "alias" : "csvmetrics",
* "driver" : "diag",
* "cycles" : "50000",
* "threads" : "1",
* "op": "log: level=debug",
* "rate" : "100.0"
* };
* scenario.start(activitydef);
* scenario.waitMillis(500);
*
* csvlogger.add(metrics.csvmetrics.cycles_servicetime);
* csvlogger.start(500,"MILLISECONDS");
*
* scenario.waitMillis(2000);
* scenario.stop(activitydef);
*
* csvlogger.report();
* }</pre>
*/
@Override
public void invoke() {
// TODO create().csvmetrics....
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_extension_csvoutput extends SCBaseScenario {
public SC_extension_csvoutput(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* var csvlogger = csvoutput.open("logs/csvoutputtestfile.csv","header1","header2");
*
* csvlogger.write({"header1": "value1","header2":"value2"});
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_extension_histostatslogger extends SCBaseScenario {
public SC_extension_histostatslogger(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "testhistostatslogger",
* "driver" : "diag",
* "cycles" : "50000",
* "threads" : "5",
* "rate" : "100.0",
* "op" : "noop"
* };
*
* histostatslogger.logHistoStats("testing extention histostatslogger", ".*", "logs/histostats.csv", "0.5s");
* print("started logging to logs/histostats.csv for all metrics at 1/2" +
* " second intervals.");
* scenario.start(activitydef);
* scenario.waitMillis(4000);
* scenario.stop(activitydef);
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 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,22 +14,24 @@
* limitations under the License.
*/
package io.nosqlbench.engine.core.script;
package io.nosqlbench.nbr.examples.injava;
import io.nosqlbench.engine.api.scripting.ScriptEnvBuffer;
import org.junit.jupiter.api.Test;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
public class NBScenarioContextBufferTest {
@Test
public void shouldCaptureLoggedOutput() throws IOException {
ScriptEnvBuffer seb = new ScriptEnvBuffer();
seb.getWriter().write("out\n");
assertThat(seb.getStdoutText()).isEqualTo("out\n");
public class SC_extension_shutdown_hook extends SCBaseScenario {
public SC_extension_shutdown_hook(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* shutdown.addShutdownHook('testfunc', function f() {
* print("shutdown hook running");
* });
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,50 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_histologger extends SCBaseScenario {
public SC_histologger(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "testhistologger",
* "driver" : "diag",
* "cycles" : "1000",
* "threads" : "20",
* "interval" : "2000",
* "targetrate" : "100.0",
* "op" : "noop"
* };
*
* histologger.logHistoIntervals("testing extention histologger", ".*", "hdrhistodata.log", "0.5s");
* print("started logging to hdrhistodata.log for all metrics at 1/2 second intervals.");
*
* scenario.start(activitydef);
* scenario.waitMillis(3000);
* scenario.stop(activitydef);
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_linkedinput extends SCBaseScenario {
public SC_linkedinput(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* var leader = {
* driver: 'diag',
* alias: 'leader',
* targetrate: '10000',
* op: 'log:level=info'
* };
*
* var follower = {
* driver: 'diag',
* alias: 'follower',
* // linkinput: 'leader',
* op: 'log:level=INFO'
* };
*
* scenario.start(leader);
* print("started leader");
* scenario.start(follower);
* print("started follower");
*
* scenario.waitMillis(500);
*
* scenario.stop(leader);
* print("stopped leader");
* scenario.stop(follower);
* print("stopped follower");
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_optimo extends SCBaseScenario {
public SC_optimo(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* var optimo = optimos.init();
*
* optimo.param('pa', 0.0, 200000.0);
* optimo.param('pb', 0.0, 200000.0);
*
* optimo.setInitialRadius(10000.0).setStoppingRadius(0.001).setMaxEval(1000);
*
* optimo.setObjectiveFunction(
* function (values) {
* // var arraydata = Java.from(ary);
* print("ary:" + JSON.stringify(values));
*
* var a = 0.0 + values.pa;
* var b = 0.0 + values.pb;
*
* var result = 1000000 - ((Math.abs(100 - a) + Math.abs(100 - b)));
* print("a=" + a + ",b=" + b + ", r=" + result);
* return result;
* }
* );
*
* var result = optimo.optimize();
*
* print("optimized result was " + result);
* print("map of result was " + result.getMap());
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_params_variable extends SCBaseScenario {
public SC_params_variable(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* print('params["one"]=\'' + params["one"] + "'");
* print('params["three"]=\'' + params["three"] + "'");
*
* var overrides = {
* 'three': "five"
* };
*
* var overridden = params.withOverrides(overrides);
*
* print('overridden["three"] [overridden-three-five]=\'' + overridden["three"] + "'");
*
* var defaults = {
* 'four': "niner"
* };
*
* var defaulted = params.withDefaults(defaults);
*
* print('defaulted.get["four"] [defaulted-four-niner]=\'' + defaulted["four"] + "'");
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_readmetrics extends SCBaseScenario {
public SC_readmetrics(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "testactivity",
* "driver" : "diag",
* "cycles" : "0..1000000000",
* "threads" : "25",
* "interval" : "2000",
* "op" : "noop"
* };
*
* scenario.start(activitydef);
*
* scenario.waitMillis(500);
* while (metrics.testactivity.cycles_servicetime.count < 1000) {
* print('waiting 10ms because cycles<10000 : ' + metrics.testactivity.cycles_servicetime.count);
* scenario.waitMillis(10);
*
* }
* scenario.stop(activitydef);
* print("count: " + metrics.testactivity.cycles_servicetime.count);
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_speedcheck extends SCBaseScenario {
public SC_speedcheck(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "speedcheck",
* "driver" : "diag",
* "cycles" : "50000",
* "threads" : "20",
* "interval" : "2000",
* "targetrate" : "10000.0",
* "op": "noop"
* };
*
* print("running 5E5 cycles at 1E5 cps ~~ 5 seconds worth");
* scenario.start(activitydef);
*
* while (scenario.isRunningActivity(activitydef)) {
* achievedRate = metrics.speedcheck.cycles.servicetime.meanRate;
* currentCycle = metrics.speedcheck.cycles.servicetime.count;
* print("currentCycle = " + currentCycle + ", mean rate = " + achievedRate);
* scenario.waitMillis(1000);
* }
*
* achievedRate = metrics.speedcheck.cycles.servicetime.meanRate;
* currentCycle = metrics.speedcheck.cycles.servicetime.count;
* print("last update - currentCycle = " + currentCycle + ", mean rate = " + achievedRate);
*
*
* scenario.stop(activitydef);
* //print('stopped scenario');
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,78 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
import java.util.Map;
public class SC_start_stop_diag extends SCBaseScenario {
public SC_start_stop_diag(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
*
* activitydef = {
* "alias" : "teststartstopdiag",
* "driver" : "diag",
* "cycles" : "0..1000000000",
* "threads" : "5",
* "interval" : "2000",
* "op" : "noop",
* "rate" : "5"
* };
*
* print('starting activity teststartstopdiag');
* scenario.start(activitydef);
*
* print('waiting 500 ms');
* scenario.waitMillis(500);
*
* print('waited, stopping activity teststartstopdiag');
* scenario.stop(activitydef);
*
* print('stopped activity teststartstopdiag');
*
* }</pre>
*/
@Override
public void invoke() {
var activitydef = Map.of(
"alias" , "teststartstopdiag",
"driver" , "diag",
"cycles" , "0..1000000000",
"threads" , "5",
"interval" , "2000",
"op" , "noop",
"rate" , "5");
stdout.println("starting activity teststartstopdiag");
controller.start(activitydef);
stdout.println("waiting 500 ms");
controller.waitMillis(500);
stdout.println("waited, stopping activity teststartstopdiag");
controller.stop(activitydef);
stdout.println("stopped activity teststartstopdiag");
}
}

View File

@@ -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,5 +14,22 @@
* limitations under the License.
*/
var sum= adder.getSum(12,34);
print('sum is ' + sum);
package io.nosqlbench.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_template extends SCBaseScenario {
public SC_template(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
*
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_threadchange extends SCBaseScenario {
public SC_threadchange(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* scenario.start("driver=diag;alias=threadchange;cycles=0..60000;threads=1;interval=2000;op='noop';rate=1000");
* activities.threadchange.threads=1;
* print("threads now " + activities.threadchange.threads);
* print('waiting 500 ms');
* scenario.waitMillis(500);
*
* activities.threadchange.threads=5;
* print("threads now " + activities.threadchange.threads);
* scenario.stop('threadchange');
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_threadspeeds extends SCBaseScenario {
public SC_threadspeeds(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* activitydef = {
* "alias" : "threadspeeds",
* "driver" : "diag",
* "cycles" : "0..4000000000000",
* "threads" : "1",
* "interval" : "10000",
* "targetrate" : "1000000",
* "op": "noop"
* };
* scenario.start(activitydef);
*
* var speeds = [];
* var latencies = [];
*
* function aTestCycle(threads, index) {
* activities.threadspeeds.threads = threads; // dynamically adjust the active threads for this activity
* scenario.waitMillis(60000); // wait for 1 minute to get a clean 1 minute average speed
* // scenario.waitMillis(5000); // wait for 1 minute to get a clean 1 minute average speed
* speeds[threads]= metrics.threadspeeds.cycles.oneMinuteRate; // record 1 minute avg speed
* print("speeds:" + speeds.toString());
*
* }
*
* var min=1;
* var max=256;
* var mid=Math.floor((min+max)/2)|0;
*
* [min,mid,max].forEach(aTestCycle);
*
* while (min<mid && mid<max && scenario.isRunningActivity(activitydef)) {
* print("speeds:" + speeds.toString());
* if (speeds[min]<speeds[max]) {
* min=mid;
* mid=Math.floor((mid+max) / 2)|0;
* } else {
* max=mid;
* mid=Math.floor((min+mid) / 2)|0;
* }
* aTestCycle(mid);
* }
* print("The optimum number of threads is " + mid + ", with " + speeds[mid] + " cps");
* var targetrate = (speeds[mid] * .7)|0;
* print("Measuring latency with threads=" + mid + " and targetrate=" + targetrate);
*
* activities.threadspeeds.threads = mid;
* activities.threadspeeds.targetrate = targetrate;
* scenario.waitMillis(60000);
*
*
* scenario.stop(threadspeeds);
* }</pre>
*/
@Override
public void invoke() {
}
}

View File

@@ -0,0 +1,48 @@
/*
* 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.nbr.examples.injava;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nbr.examples.SCBaseScenario;
public class SC_undef_param extends SCBaseScenario {
public SC_undef_param(NBComponent parentComponent, String scenarioName) {
super(parentComponent, scenarioName);
}
/** <pre>{@code
* print("params from command line:");
* print(params);
* print('before: params["three"]:' + params["three"]);
* print('before: params.three:' + params.three);
*
* var overrides = {
* 'three': "undef",
* };
*
* print("params.three after overriding with three:UNDEF");
* params = params.withOverrides({'three':'UNDEF'});
* print(params);
* print('after: params["three"]:' + params["three"]);
* print('after: params.three:' + params.three);
* }</pre>
*/
@Override
public void invoke() {
}
}

14
pom.xml
View File

@@ -50,7 +50,7 @@
<module.nbr>nbr</module.nbr>
<module.nb-spectest>nb-spectest</module.nb-spectest>
<module.nbr-examples>nbr-examples</module.nbr-examples>
<!-- <module.nbr-examples>nbr-examples</module.nbr-examples>-->
<!-- driver modules -->
<module.adapter-diag>adapter-diag</module.adapter-diag>
@@ -85,7 +85,7 @@
<module>nb5-proof</module>
<module>nb5</module>
<module>nbr</module>
<module>nbr-examples</module>
<!-- <module>nbr-examples</module>-->
<module>nb-api</module>
<module>nb-annotations</module>
<module>nb-spectest</module>
@@ -165,16 +165,6 @@
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.4.5</version>
</plugin>
</plugins>
</reporting>
<developers>
<developer>
<name>Jonathan Shook</name>