mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
cleanups and formatting
This commit is contained in:
@@ -98,22 +98,22 @@ public class SimpleActivity implements Activity {
|
||||
this.parentLabels = parentLabels;
|
||||
if (activityDef.getAlias().equals(ActivityDef.DEFAULT_ALIAS)) {
|
||||
Optional<String> workloadOpt = activityDef.getParams().getOptionalString(
|
||||
"workload",
|
||||
"yaml"
|
||||
"workload",
|
||||
"yaml"
|
||||
);
|
||||
if (workloadOpt.isPresent()) {
|
||||
activityDef.getParams().set("alias", workloadOpt.get());
|
||||
} else {
|
||||
activityDef.getParams().set("alias",
|
||||
activityDef.getActivityType().toUpperCase(Locale.ROOT)
|
||||
+ nameEnumerator);
|
||||
activityDef.getActivityType().toUpperCase(Locale.ROOT)
|
||||
+ nameEnumerator);
|
||||
nameEnumerator++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleActivity(String activityDefString, NBLabeledElement parentLabels) {
|
||||
this(ActivityDef.parseActivityDef(activityDefString),parentLabels);
|
||||
this(ActivityDef.parseActivityDef(activityDefString), parentLabels);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,8 +124,8 @@ public class SimpleActivity implements Activity {
|
||||
public synchronized NBErrorHandler getErrorHandler() {
|
||||
if (null == this.errorHandler) {
|
||||
errorHandler = new NBErrorHandler(
|
||||
() -> activityDef.getParams().getOptionalString("errors").orElse("stop"),
|
||||
() -> getExceptionMetrics());
|
||||
() -> activityDef.getParams().getOptionalString("errors").orElse("stop"),
|
||||
() -> getExceptionMetrics());
|
||||
}
|
||||
return errorHandler;
|
||||
}
|
||||
@@ -324,12 +324,12 @@ public class SimpleActivity implements Activity {
|
||||
public synchronized void initOrUpdateRateLimiters(ActivityDef activityDef) {
|
||||
|
||||
activityDef.getParams().getOptionalNamedParameter("striderate")
|
||||
.map(RateSpec::new)
|
||||
.ifPresent(spec -> strideLimiter = RateLimiters.createOrUpdate(this, "strides", strideLimiter, spec));
|
||||
.map(RateSpec::new)
|
||||
.ifPresent(spec -> strideLimiter = RateLimiters.createOrUpdate(this, "strides", strideLimiter, spec));
|
||||
|
||||
activityDef.getParams().getOptionalNamedParameter("cyclerate", "targetrate", "rate")
|
||||
.map(RateSpec::new).ifPresent(
|
||||
spec -> cycleLimiter = RateLimiters.createOrUpdate(this, "cycles", cycleLimiter, spec));
|
||||
.map(RateSpec::new).ifPresent(
|
||||
spec -> cycleLimiter = RateLimiters.createOrUpdate(this, "cycles", cycleLimiter, spec));
|
||||
|
||||
}
|
||||
|
||||
@@ -338,7 +338,8 @@ public class SimpleActivity implements Activity {
|
||||
* length of the sequence as determined by the provided ratios. Also, modify the ActivityDef with reasonable
|
||||
* defaults when requested.
|
||||
*
|
||||
* @param seq - The {@link OpSequence} to derive the defaults from
|
||||
* @param seq
|
||||
* - The {@link OpSequence} to derive the defaults from
|
||||
*/
|
||||
public synchronized void setDefaultsFromOpSequence(OpSequence<?> seq) {
|
||||
Optional<String> strideOpt = getParams().getOptionalString("stride");
|
||||
@@ -358,15 +359,15 @@ public class SimpleActivity implements Activity {
|
||||
} else {
|
||||
if (0 == activityDef.getCycleCount()) {
|
||||
throw new RuntimeException(
|
||||
"You specified cycles, but the range specified means zero cycles: " + getParams().get("cycles")
|
||||
"You specified cycles, but the range specified means zero cycles: " + getParams().get("cycles")
|
||||
);
|
||||
}
|
||||
long stride = getParams().getOptionalLong("stride").orElseThrow();
|
||||
long cycles = this.activityDef.getCycleCount();
|
||||
if (cycles < stride) {
|
||||
throw new RuntimeException(
|
||||
"The specified cycles (" + cycles + ") are less than the stride (" + stride + "). This means there aren't enough cycles to cause a stride to be executed." +
|
||||
" If this was intended, then set stride low enough to allow it."
|
||||
"The specified cycles (" + cycles + ") are less than the stride (" + stride + "). This means there aren't enough cycles to cause a stride to be executed." +
|
||||
" If this was intended, then set stride low enough to allow it."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -376,7 +377,7 @@ public class SimpleActivity implements Activity {
|
||||
|
||||
if (0 < stride && 0 != cycleCount % stride) {
|
||||
logger.warn(() -> "The stride does not evenly divide cycles. Only full strides will be executed," +
|
||||
"leaving some cycles unused. (stride=" + stride + ", cycles=" + cycleCount + ')');
|
||||
"leaving some cycles unused. (stride=" + stride + ", cycles=" + cycleCount + ')');
|
||||
}
|
||||
|
||||
Optional<String> threadSpec = activityDef.getParams().getOptionalString("threads");
|
||||
@@ -407,15 +408,15 @@ public class SimpleActivity implements Activity {
|
||||
|
||||
if (activityDef.getThreads() > activityDef.getCycleCount()) {
|
||||
logger.warn(() -> "threads=" + activityDef.getThreads() + " and cycles=" + activityDef.getCycleSummary()
|
||||
+ ", you should have more cycles than threads.");
|
||||
+ ", you should have more cycles than threads.");
|
||||
}
|
||||
|
||||
} else if (1000 < cycleCount) {
|
||||
logger.warn(() -> "For testing at scale, it is highly recommended that you " +
|
||||
"set threads to a value higher than the default of 1." +
|
||||
" hint: you can use threads=auto for reasonable default, or" +
|
||||
" consult the topic on threads with `help threads` for" +
|
||||
" more information.");
|
||||
"set threads to a value higher than the default of 1." +
|
||||
" hint: you can use threads=auto for reasonable default, or" +
|
||||
" consult the topic on threads with `help threads` for" +
|
||||
" more information.");
|
||||
}
|
||||
|
||||
if (0 < this.activityDef.getCycleCount() && 0 == seq.getOps().size()) {
|
||||
@@ -426,11 +427,11 @@ public class SimpleActivity implements Activity {
|
||||
/**
|
||||
* Given a function that can create an op of type <O> from a CommandTemplate, generate
|
||||
* an indexed sequence of ready to call operations.
|
||||
*
|
||||
* <p>
|
||||
* This method works almost exactly like the ,
|
||||
* except that it uses the {@link CommandTemplate} semantics, which are more general and allow
|
||||
* for map-based specification of operations with bindings in each field.
|
||||
*
|
||||
* <p>
|
||||
* It is recommended to use the CommandTemplate form
|
||||
* than the
|
||||
*
|
||||
@@ -440,8 +441,8 @@ public class SimpleActivity implements Activity {
|
||||
* @return
|
||||
*/
|
||||
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSequenceFromCommands(
|
||||
Function<CommandTemplate, OpDispenser<O>> opinit,
|
||||
boolean strict
|
||||
Function<CommandTemplate, OpDispenser<O>> opinit,
|
||||
boolean strict
|
||||
) {
|
||||
Function<OpTemplate, CommandTemplate> f = CommandTemplate::new;
|
||||
Function<OpTemplate, OpDispenser<? extends O>> opTemplateOFunction = f.andThen(opinit);
|
||||
@@ -450,10 +451,10 @@ public class SimpleActivity implements Activity {
|
||||
}
|
||||
|
||||
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSourceFromParsedOps(
|
||||
Map<String, DriverAdapter> adapterCache,
|
||||
Map<String, OpMapper<Op>> mapperCache,
|
||||
List<DriverAdapter> adapters,
|
||||
List<ParsedOp> pops
|
||||
Map<String, DriverAdapter> adapterCache,
|
||||
Map<String, OpMapper<Op>> mapperCache,
|
||||
List<DriverAdapter> adapters,
|
||||
List<ParsedOp> pops
|
||||
) {
|
||||
try {
|
||||
|
||||
@@ -466,9 +467,9 @@ public class SimpleActivity implements Activity {
|
||||
}
|
||||
|
||||
SequencerType sequencerType = getParams()
|
||||
.getOptionalString("seq")
|
||||
.map(SequencerType::valueOf)
|
||||
.orElse(SequencerType.bucket);
|
||||
.getOptionalString("seq")
|
||||
.map(SequencerType::valueOf)
|
||||
.orElse(SequencerType.bucket);
|
||||
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
|
||||
|
||||
int dryrunCount = 0;
|
||||
@@ -512,10 +513,10 @@ public class SimpleActivity implements Activity {
|
||||
|
||||
|
||||
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSourceFromCommands(
|
||||
Function<ParsedOp, OpDispenser<? extends O>> opinit,
|
||||
NBConfiguration cfg,
|
||||
List<Function<Map<String, Object>, Map<String, Object>>> parsers,
|
||||
boolean strict
|
||||
Function<ParsedOp, OpDispenser<? extends O>> opinit,
|
||||
NBConfiguration cfg,
|
||||
List<Function<Map<String, Object>, Map<String, Object>>> parsers,
|
||||
boolean strict
|
||||
) {
|
||||
Function<OpTemplate, ParsedOp> f = t -> new ParsedOp(t, cfg, parsers, this);
|
||||
Function<OpTemplate, OpDispenser<? extends O>> opTemplateOFunction = f.andThen(opinit);
|
||||
@@ -525,7 +526,7 @@ public class SimpleActivity implements Activity {
|
||||
|
||||
protected List<ParsedOp> loadParsedOps(NBConfiguration cfg, Optional<DriverAdapter> defaultAdapter) {
|
||||
List<ParsedOp> parsedOps = loadOpTemplates(defaultAdapter).stream().map(
|
||||
ot -> new ParsedOp(ot, cfg, List.of(), this)
|
||||
ot -> new ParsedOp(ot, cfg, List.of(), this)
|
||||
).toList();
|
||||
return parsedOps;
|
||||
}
|
||||
@@ -546,21 +547,21 @@ public class SimpleActivity implements Activity {
|
||||
// There were no ops, and it was because they were all filtered out
|
||||
if (0 < unfilteredOps.size()) {
|
||||
throw new BasicError("There were no active op templates with tag filter '"
|
||||
+ tagfilter + "', since all " + unfilteredOps.size() + " were filtered out.");
|
||||
+ tagfilter + "', since all " + unfilteredOps.size() + " were filtered out.");
|
||||
}
|
||||
if (defaultDriverAdapter.isPresent() && defaultDriverAdapter.get() instanceof SyntheticOpTemplateProvider sotp) {
|
||||
filteredOps = sotp.getSyntheticOpTemplates(opsDocList, this.activityDef.getParams());
|
||||
Objects.requireNonNull(filteredOps);
|
||||
if (0 == filteredOps.size()) {
|
||||
throw new BasicError("Attempted to create synthetic ops from driver '" + defaultDriverAdapter.get().getAdapterName() + '\'' +
|
||||
" but no ops were created. You must provide either a workload or an op parameter. Activities require op templates.");
|
||||
" but no ops were created. You must provide either a workload or an op parameter. Activities require op templates.");
|
||||
}
|
||||
} else {
|
||||
throw new BasicError("""
|
||||
No op templates were provided. You must provide one of these activity parameters:
|
||||
1) workload=some.yaml
|
||||
2) op='inline template'
|
||||
3) driver=stdout (or any other drive that can synthesize ops)""");
|
||||
No op templates were provided. You must provide one of these activity parameters:
|
||||
1) workload=some.yaml
|
||||
2) op='inline template'
|
||||
3) driver=stdout (or any other drive that can synthesize ops)""");
|
||||
}
|
||||
if (0 == filteredOps.size()) {
|
||||
throw new BasicError("There were no active op templates with tag filter '" + tagfilter + '\'');
|
||||
@@ -569,19 +570,19 @@ public class SimpleActivity implements Activity {
|
||||
|
||||
if (0 == filteredOps.size()) {
|
||||
throw new OpConfigError("No op templates found. You must provide either workload=... or op=..., or use " +
|
||||
"a default driver (driver=___). This includes " +
|
||||
ServiceLoader.load(DriverAdapter.class).stream()
|
||||
.filter(p -> {
|
||||
AnnotatedType[] annotatedInterfaces = p.type().getAnnotatedInterfaces();
|
||||
for (AnnotatedType ai : annotatedInterfaces) {
|
||||
if (ai.getType().equals(SyntheticOpTemplateProvider.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map(d -> d.get().getAdapterName())
|
||||
.collect(Collectors.joining(",")));
|
||||
"a default driver (driver=___). This includes " +
|
||||
ServiceLoader.load(DriverAdapter.class).stream()
|
||||
.filter(p -> {
|
||||
AnnotatedType[] annotatedInterfaces = p.type().getAnnotatedInterfaces();
|
||||
for (AnnotatedType ai : annotatedInterfaces) {
|
||||
if (ai.getType().equals(SyntheticOpTemplateProvider.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map(d -> d.get().getAdapterName())
|
||||
.collect(Collectors.joining(",")));
|
||||
}
|
||||
|
||||
return filteredOps;
|
||||
@@ -590,7 +591,7 @@ public class SimpleActivity implements Activity {
|
||||
/**
|
||||
* Given a function that can create an op of type <O> from an OpTemplate, generate
|
||||
* an indexed sequence of ready to call operations.
|
||||
*
|
||||
* <p>
|
||||
* This method uses the following conventions to derive the sequence:
|
||||
*
|
||||
* <OL>
|
||||
@@ -604,9 +605,11 @@ public class SimpleActivity implements Activity {
|
||||
* where the sequence length is the sum of the ratios.</LI>
|
||||
* </OL>
|
||||
*
|
||||
* @param <O> A holder for an executable operation for the native driver used by this activity.
|
||||
* @param opinit A function to map an OpTemplate to the executable operation form required by
|
||||
* the native driver for this activity.
|
||||
* @param <O>
|
||||
* A holder for an executable operation for the native driver used by this activity.
|
||||
* @param opinit
|
||||
* A function to map an OpTemplate to the executable operation form required by
|
||||
* the native driver for this activity.
|
||||
* @param defaultAdapter
|
||||
* @return The sequence of operations as determined by filtering and ratios
|
||||
*/
|
||||
@@ -624,9 +627,9 @@ public class SimpleActivity implements Activity {
|
||||
}
|
||||
|
||||
SequencerType sequencerType = getParams()
|
||||
.getOptionalString("seq")
|
||||
.map(SequencerType::valueOf)
|
||||
.orElse(SequencerType.bucket);
|
||||
.getOptionalString("seq")
|
||||
.map(SequencerType::valueOf)
|
||||
.orElse(SequencerType.bucket);
|
||||
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
|
||||
|
||||
try {
|
||||
@@ -654,7 +657,7 @@ public class SimpleActivity implements Activity {
|
||||
if (stmt.isPresent()) {
|
||||
String op = stmt.get();
|
||||
workloadSource = "commandline:" + stmt.get();
|
||||
if (op.startsWith("{")||op.startsWith("[")) {
|
||||
if (op.startsWith("{") || op.startsWith("[")) {
|
||||
return OpsLoader.loadString(stmt.get(), OpTemplateFormat.json, activityDef.getParams(), null);
|
||||
} else {
|
||||
return OpsLoader.loadString(stmt.get(), OpTemplateFormat.inline, activityDef.getParams(), null);
|
||||
@@ -670,7 +673,6 @@ public class SimpleActivity implements Activity {
|
||||
} catch (Exception e) {
|
||||
throw new OpConfigError("Error loading op templates: " + e, workloadSource, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,15 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.api.Shutdownable;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.api.config.NBLabels;
|
||||
@@ -25,15 +33,7 @@ import io.nosqlbench.api.engine.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
|
||||
import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.nb.annotations.ServiceSelector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -152,6 +152,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
setDefaultsFromOpSequence(sequence);
|
||||
}
|
||||
|
||||
|
||||
public OpSequence<OpDispenser<? extends Op>> getOpSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
* for scenario encapsulation and concurrent testing.
|
||||
*
|
||||
* @param args
|
||||
* Command Line Args
|
||||
* Command Line Args
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
try {
|
||||
@@ -157,17 +157,17 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
this.sessionName = SessionNamer.format(globalOptions.getSessionName());
|
||||
|
||||
NBCLI.loggerConfig
|
||||
.setSessionName(sessionName)
|
||||
.setConsoleLevel(globalOptions.getConsoleLogLevel())
|
||||
.setConsolePattern(globalOptions.getConsoleLoggingPattern())
|
||||
.setLogfileLevel(globalOptions.getScenarioLogLevel())
|
||||
.setLogfilePattern(globalOptions.getLogfileLoggingPattern())
|
||||
.setLoggerLevelOverrides(globalOptions.getLogLevelOverrides())
|
||||
.setMaxLogs(globalOptions.getLogsMax())
|
||||
.setLogsDirectory(globalOptions.getLogsDirectory())
|
||||
.setAnsiEnabled(globalOptions.isEnableAnsi())
|
||||
.setDedicatedVerificationLogger(globalOptions.isDedicatedVerificationLogger())
|
||||
.activate();
|
||||
.setSessionName(sessionName)
|
||||
.setConsoleLevel(globalOptions.getConsoleLogLevel())
|
||||
.setConsolePattern(globalOptions.getConsoleLoggingPattern())
|
||||
.setLogfileLevel(globalOptions.getScenarioLogLevel())
|
||||
.setLogfilePattern(globalOptions.getLogfileLoggingPattern())
|
||||
.setLoggerLevelOverrides(globalOptions.getLogLevelOverrides())
|
||||
.setMaxLogs(globalOptions.getLogsMax())
|
||||
.setLogsDirectory(globalOptions.getLogsDirectory())
|
||||
.setAnsiEnabled(globalOptions.isEnableAnsi())
|
||||
.setDedicatedVerificationLogger(globalOptions.isDedicatedVerificationLogger())
|
||||
.activate();
|
||||
ConfigurationFactory.setConfigurationFactory(NBCLI.loggerConfig);
|
||||
|
||||
NBCLI.logger = LogManager.getLogger("NBCLI");
|
||||
@@ -210,17 +210,16 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
final String reportPromPushTo = globalOptions.wantsReportPromPushTo();
|
||||
|
||||
|
||||
|
||||
final int mOpts = (dockerMetrics ? 1 : 0)
|
||||
+ ((null != dockerMetricsAt) ? 1 : 0)
|
||||
+ ((null != reportGraphiteTo) ? 1 : 0);
|
||||
+ ((null != dockerMetricsAt) ? 1 : 0)
|
||||
+ ((null != reportGraphiteTo) ? 1 : 0);
|
||||
|
||||
if ((1 < mOpts) && ((null == reportGraphiteTo) || (null == annotatorsConfig)))
|
||||
throw new BasicError("You have multiple conflicting options which attempt to set\n" +
|
||||
" the destination for metrics and annotations. Please select only one of\n" +
|
||||
" --docker-metrics, --docker-metrics-at <addr>, or other options like \n" +
|
||||
" --report-graphite-to <addr> and --annotators <config>\n" +
|
||||
" For more details, see run 'nb help docker-metrics'");
|
||||
" the destination for metrics and annotations. Please select only one of\n" +
|
||||
" --docker-metrics, --docker-metrics-at <addr>, or other options like \n" +
|
||||
" --report-graphite-to <addr> and --annotators <config>\n" +
|
||||
" For more details, see run 'nb help docker-metrics'");
|
||||
|
||||
String graphiteMetricsAddress = null;
|
||||
|
||||
@@ -229,18 +228,18 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
NBCLI.logger.info("Docker metrics is enabled. Docker must be installed for this to work");
|
||||
final DockerMetricsManager dmh = new DockerMetricsManager();
|
||||
final Map<String, String> dashboardOptions = Map.of(
|
||||
DockerMetricsManager.GRAFANA_TAG, globalOptions.getDockerGrafanaTag(),
|
||||
DockerMetricsManager.PROM_TAG, globalOptions.getDockerPromTag(),
|
||||
DockerMetricsManager.TSDB_RETENTION, String.valueOf(globalOptions.getDockerPromRetentionDays()),
|
||||
DockerMetricsManager.GRAPHITE_SAMPLE_EXPIRY, "10m",
|
||||
DockerMetricsManager.GRAPHITE_CACHE_SIZE, "5000",
|
||||
DockerMetricsManager.GRAPHITE_LOG_LEVEL, globalOptions.getGraphiteLogLevel(),
|
||||
DockerMetricsManager.GRAPHITE_LOG_FORMAT, "logfmt"
|
||||
DockerMetricsManager.GRAFANA_TAG, globalOptions.getDockerGrafanaTag(),
|
||||
DockerMetricsManager.PROM_TAG, globalOptions.getDockerPromTag(),
|
||||
DockerMetricsManager.TSDB_RETENTION, String.valueOf(globalOptions.getDockerPromRetentionDays()),
|
||||
DockerMetricsManager.GRAPHITE_SAMPLE_EXPIRY, "10m",
|
||||
DockerMetricsManager.GRAPHITE_CACHE_SIZE, "5000",
|
||||
DockerMetricsManager.GRAPHITE_LOG_LEVEL, globalOptions.getGraphiteLogLevel(),
|
||||
DockerMetricsManager.GRAPHITE_LOG_FORMAT, "logfmt"
|
||||
|
||||
);
|
||||
dmh.startMetrics(dashboardOptions);
|
||||
final String warn = "Docker Containers are started, for grafana and prometheus, hit" +
|
||||
" these urls in your browser: http://<host>:3000 and http://<host>:9090";
|
||||
" these urls in your browser: http://<host>:3000 and http://<host>:9090";
|
||||
NBCLI.logger.warn(warn);
|
||||
graphiteMetricsAddress = "localhost";
|
||||
} else if (null != dockerMetricsAt) graphiteMetricsAddress = dockerMetricsAt;
|
||||
@@ -313,19 +312,19 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
NBCLI.logger.debug(() -> "user requests to copy out " + resourceToCopy);
|
||||
|
||||
Optional<Content<?>> tocopy = NBIO.classpath()
|
||||
.searchPrefixes("activities")
|
||||
.searchPrefixes(options.wantsIncludes())
|
||||
.pathname(resourceToCopy).extensionSet(RawOpsLoader.YAML_EXTENSIONS).first();
|
||||
.searchPrefixes("activities")
|
||||
.searchPrefixes(options.wantsIncludes())
|
||||
.pathname(resourceToCopy).extensionSet(RawOpsLoader.YAML_EXTENSIONS).first();
|
||||
|
||||
if (tocopy.isEmpty()) tocopy = NBIO.classpath()
|
||||
.searchPrefixes().searchPrefixes(options.wantsIncludes())
|
||||
.searchPrefixes(options.wantsIncludes())
|
||||
.pathname(resourceToCopy).first();
|
||||
.searchPrefixes().searchPrefixes(options.wantsIncludes())
|
||||
.searchPrefixes(options.wantsIncludes())
|
||||
.pathname(resourceToCopy).first();
|
||||
|
||||
final Content<?> data = tocopy.orElseThrow(
|
||||
() -> new BasicError(
|
||||
"Unable to find " + resourceToCopy +
|
||||
" in classpath to copy out")
|
||||
() -> new BasicError(
|
||||
"Unable to find " + resourceToCopy +
|
||||
" in classpath to copy out")
|
||||
);
|
||||
|
||||
final Path writeTo = Path.of(data.asPath().getFileName().toString());
|
||||
@@ -363,7 +362,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
if (options.wantsTopicalHelp()) {
|
||||
final Optional<String> helpDoc = MarkdownFinder.forHelpTopic(options.wantsTopicalHelpFor());
|
||||
System.out.println(helpDoc.orElseThrow(
|
||||
() -> new RuntimeException("No help could be found for " + options.wantsTopicalHelpFor())
|
||||
() -> new RuntimeException("No help could be found for " + options.wantsTopicalHelpFor())
|
||||
));
|
||||
return NBCLI.EXIT_OK;
|
||||
}
|
||||
@@ -410,13 +409,13 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
}
|
||||
|
||||
for (
|
||||
final LoggerConfigData histoLogger : options.getHistoLoggerConfigs())
|
||||
final LoggerConfigData histoLogger : options.getHistoLoggerConfigs())
|
||||
ActivityMetrics.addHistoLogger(sessionName, histoLogger.pattern, histoLogger.file, histoLogger.interval);
|
||||
for (
|
||||
final LoggerConfigData statsLogger : options.getStatsLoggerConfigs())
|
||||
final LoggerConfigData statsLogger : options.getStatsLoggerConfigs())
|
||||
ActivityMetrics.addStatsLogger(sessionName, statsLogger.pattern, statsLogger.file, statsLogger.interval);
|
||||
for (
|
||||
final LoggerConfigData classicConfigs : options.getClassicHistoConfigs())
|
||||
final LoggerConfigData classicConfigs : options.getClassicHistoConfigs())
|
||||
ActivityMetrics.addClassicHistos(sessionName, classicConfigs.pattern, classicConfigs.file, classicConfigs.interval);
|
||||
|
||||
// intentionally not shown for warn-only
|
||||
@@ -442,8 +441,8 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
this);
|
||||
|
||||
final ScriptBuffer buffer = new BasicScriptBuffer()
|
||||
.add(options.getCommands()
|
||||
.toArray(new Cmd[0]));
|
||||
.add(options.getCommands()
|
||||
.toArray(new Cmd[0]));
|
||||
final String scriptData = buffer.getParsedScript();
|
||||
|
||||
if (options.wantsShowScript()) {
|
||||
|
||||
@@ -80,7 +80,6 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NBLabels getLabels() {
|
||||
return this.parentComponent.getLabels().andTypes("scenario", this.scenarioName);
|
||||
@@ -142,15 +141,6 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
|
||||
return new Scenario(name, null, engine, "console:10s", true, true, reportSummaryTo, "", Path.of("logs"), minMaturity, NBLabeledElement.forKV("test-name", "name"));
|
||||
}
|
||||
|
||||
// public Scenario(final String name, final Engine engine, final String reportSummaryTo, final Maturity minMaturity) {
|
||||
// scenarioName = name;
|
||||
// this.reportSummaryTo = reportSummaryTo;
|
||||
// this.engine = engine;
|
||||
// commandLine = "";
|
||||
// this.minMaturity = minMaturity;
|
||||
// logsPath = Path.of("logs");
|
||||
// }
|
||||
//
|
||||
public Scenario setLogger(final Logger logger) {
|
||||
this.logger = logger;
|
||||
return this;
|
||||
|
||||
@@ -48,79 +48,4 @@ public interface NBLabeledElement extends NBComponent {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// NBLabeledElement EMPTY = forMap(Map.of());
|
||||
//
|
||||
// Map<String, String> getLabels();
|
||||
//
|
||||
// /**
|
||||
// * TODO: Should throw an error when new keys are duplicated
|
||||
// * @param keyvalues
|
||||
// * @return
|
||||
// */
|
||||
// default Map<String, String> getLabelsAnd(final String... keyvalues) {
|
||||
// final LinkedHashMap<String, String> map = new LinkedHashMap<>(this.getLabels());
|
||||
// for (int idx = 0; idx < keyvalues.length; idx+=2) map.put(keyvalues[idx], keyvalues[idx + 1]);
|
||||
// return map;
|
||||
// }
|
||||
//
|
||||
//// default NBLabeledElement and(String... keyvalues) {
|
||||
////
|
||||
//// }
|
||||
//
|
||||
// default Map<String, String> getLabelsAnd(final Map<String,String> extra) {
|
||||
// final LinkedHashMap<String,String> map = new LinkedHashMap<>(this.getLabels());
|
||||
// map.putAll(extra);
|
||||
// return map;
|
||||
// }
|
||||
//
|
||||
// static MapLabels forMap(final Map<String,String> labels) {
|
||||
// return new MapLabels(labels);
|
||||
// }
|
||||
//
|
||||
// class MapLabels implements NBLabeledElement {
|
||||
// private final Map<String, String> labels;
|
||||
//
|
||||
// public MapLabels(final Map<String,String> labels) {
|
||||
// this.labels = labels;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Map<String, String> getLabels() {
|
||||
// return this.labels;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Create a single String representation of the label set, preserving key order,
|
||||
// * with optional additional labels, in the form of:
|
||||
// * <pre>{@code
|
||||
// * key1:value1,key2:value2,...
|
||||
// * }</pre>
|
||||
// * @param and
|
||||
// * @return
|
||||
// */
|
||||
// default String linearizeLabels(final Map<String,String> and) {
|
||||
// final StringBuilder sb= new StringBuilder();
|
||||
// final Map<String, String> allLabels = getLabelsAnd(and);
|
||||
// final ArrayList<String> sortedLabels = new ArrayList<>(allLabels.keySet());
|
||||
// for (final String label : sortedLabels) sb.append(label).append(':').append(allLabels.get(label)).append(',');
|
||||
// sb.setLength(sb.length()-",".length());
|
||||
// return sb.toString();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Equivalent to {@link #linearizeLabels(Map)}, except that additional key-value pairs can
|
||||
// * be expressed as a pairs of Strings in the argument list.
|
||||
// * @param and - An even numbered list of strings as key1, value1, key2, value2, ...
|
||||
// * @return A linearized string representation
|
||||
// */
|
||||
// default String linearizeLabels(final String... and) {
|
||||
// return this.linearizeLabels(this.getLabelsAnd(and));
|
||||
// }
|
||||
//
|
||||
// default String linearizeLabelsByValueGraphite(final String... and) {
|
||||
// return this.linearizeLabelsByValueDelim(".",and);
|
||||
// }
|
||||
//
|
||||
}
|
||||
|
||||
@@ -131,14 +131,14 @@ public interface NBLabels {
|
||||
* @param labelName The named label to modify
|
||||
* @param transform A Lambda which will modify the existing value.
|
||||
* @return A new NBLabels value, separate from the original
|
||||
* @@throws RuntimeException if either the key is not found or the values is null.
|
||||
* @throws RuntimeException if either the key is not found or the values is null.
|
||||
*/
|
||||
NBLabels modifyValue(String labelName, Function<String,String> transform);
|
||||
|
||||
/**
|
||||
* Create a new NBLabels value with the additional keys and values appended.
|
||||
*
|
||||
* @param labelsAndValues
|
||||
* @param typeLabelsAndValues
|
||||
* Keys and values in "key1", "value1", "key2", "value2", ... form
|
||||
* @return A new NBLabels instance
|
||||
*/
|
||||
@@ -147,9 +147,7 @@ public interface NBLabels {
|
||||
NBLabels and(NBLabels labels);
|
||||
/**
|
||||
* Create a new NBLabels value with the additional keys and values appended.
|
||||
*
|
||||
* @param labels
|
||||
* a map of keys and values
|
||||
* @param typeLabelsAndValues a map of keys and values
|
||||
* @return A new NBLabels instance
|
||||
*/
|
||||
NBLabels andTypes(Map<String, String> typeLabelsAndValues);
|
||||
@@ -166,7 +164,7 @@ public interface NBLabels {
|
||||
* @throws RuntimeException
|
||||
* if the specified label does not exist in the set, or the value is null.
|
||||
*/
|
||||
String only(String name);
|
||||
String valueOf(String name);
|
||||
|
||||
/**
|
||||
* Return a map representation of the label set, regardless of the underlying form.
|
||||
|
||||
Reference in New Issue
Block a user