From 777c4aa3c770d8fa0d268e6ce3e51c8c1f064aa7 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Mon, 23 Oct 2023 23:54:31 -0500 Subject: [PATCH] post merge fixes --- .../activities/baselinesv2/cql_vector2.yaml | 6 +-- .../api/activityimpl/SimpleActivity.java | 2 +- .../uniform/StandardActivity.java | 24 ++++++++- .../uniform/StandardActivityType.java | 44 ++++++---------- .../api/scenarios/NBCLIScenarioParser.java | 6 +++ .../lifecycle/activity/ActivityExecutor.java | 7 ++- .../context/ScenarioActivitiesController.java | 1 + .../scenario/execution/ScenariosExecutor.java | 52 +++++++++++-------- .../core/lifecycle/session/NBSession.java | 2 + mvn-defaults/pom.xml | 10 ++-- .../reporters/PromExpositionFormat.java | 7 +++ .../components/NBBaseComponent.java | 4 +- nb_521.md | 2 - 13 files changed, 102 insertions(+), 65 deletions(-) diff --git a/adapter-cqld4/src/main/resources/activities/baselinesv2/cql_vector2.yaml b/adapter-cqld4/src/main/resources/activities/baselinesv2/cql_vector2.yaml index 10d862e4f..25610b48d 100644 --- a/adapter-cqld4/src/main/resources/activities/baselinesv2/cql_vector2.yaml +++ b/adapter-cqld4/src/main/resources/activities/baselinesv2/cql_vector2.yaml @@ -15,7 +15,7 @@ description: | scenarios: cassandra: - drop: run tags='block:drop' labels='target:astra' threads===1 cycles===2 + drop: run tags='block:drop' threads==undef cycles==undef # nb5 cql-vector2 cassandra.schema host=localhost localdc=datacenter1 dimensions=100 schema: run tags='block:schema' threads==undef cycles==undef # nb5 cql-vector2 cassandra.rampup host=localhost localdc=datacenter1 dimensions=100 trainsize=1000000 dataset=glove-100-angular rate=10000 @@ -25,8 +25,8 @@ scenarios: run alias=search_and_index tags='block:search_and_index,optype=select' labels='target:cassandra' cycles=TEMPLATE(testsize) errors=counter,warn threads=1 astra_vectors: - drop: run tags='block:drop' labels='target:astra' threads===1 cycles===2 driverconfig=app.conf - schema: run tags='block:schema' labels='target:astra' threads===1 cycles===2 + drop: run tags='block:drop' labels='target:astra' threads==undef cycles==undef driverconfig=app.conf + schema: run tags='block:schema' labels='target:astra' threads==undef cycles==undef rampup: run tags='block:rampup' labels='target:astra' threads=100 cycles=TEMPLATE(trainsize) errors=counter # search_and_index_unthrottled: >- # run tags='block:search_and_index,optype=select' labels='target:astra' diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java index 34c6d5ab3..685f51dee 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java @@ -202,7 +202,7 @@ public class SimpleActivity extends NBBaseComponent implements Activity { } public String toString() { - return activityDef.getAlias() + ':' + this.runState + ':' + this.tally; + return (activityDef!=null ? activityDef.getAlias() : "unset_alias" ) + ':' + this.runState + ':' + this.tally ; } @Override diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivity.java b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivity.java index 0c1cdb95a..d6cbe4585 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivity.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivity.java @@ -36,6 +36,7 @@ import io.nosqlbench.api.errors.OpConfigError; import io.nosqlbench.api.labels.NBLabels; import io.nosqlbench.components.events.NBEvent; import io.nosqlbench.components.events.ParamChange; +import io.nosqlbench.engine.api.activityapi.core.ActivityDefObserver; import io.nosqlbench.engine.api.activityapi.planning.OpSequence; import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.CycleRateSpec; import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.StrideRateSpec; @@ -55,7 +56,7 @@ import java.util.concurrent.ConcurrentHashMap; * @param A type of runnable which wraps the operations for this type of driver. * @param The context type for the activity, AKA the 'space' for a named driver instance and its associated object graph */ -public class StandardActivity extends SimpleActivity implements SyntheticOpTemplateProvider { +public class StandardActivity extends SimpleActivity implements SyntheticOpTemplateProvider, ActivityDefObserver { private static final Logger logger = LogManager.getLogger("ACTIVITY"); private final OpSequence> sequence; @@ -203,6 +204,25 @@ public class StandardActivity extends SimpleActivity implements } } +// @Override +// public synchronized void onActivityDefUpdate(final ActivityDef activityDef) { +// super.onActivityDefUpdate(activityDef); +// +// for (final DriverAdapter adapter : this.adapters.values()) +// if (adapter instanceof NBReconfigurable reconfigurable) { +// NBConfigModel cfgModel = reconfigurable.getReconfigModel(); +// final Optional op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload"); +// if (op_yaml_loc.isPresent()) { +// final Map disposable = new LinkedHashMap<>(activityDef.getParams()); +// final OpsDocList workload = OpsLoader.loadPath(op_yaml_loc.get(), disposable, "activities"); +// cfgModel = cfgModel.add(workload.getConfigModel()); +// } +// final NBConfiguration cfg = cfgModel.apply(activityDef.getParams()); +// reconfigurable.applyReconfig(cfg); +// } +// +// } + @Override public List getSyntheticOpTemplates(OpsDocList opsDocList, Map cfg) { List opTemplates = new ArrayList<>(); @@ -257,4 +277,6 @@ public class StandardActivity extends SimpleActivity implements default -> super.onEvent(event); } } + + } diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivityType.java b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivityType.java index abd055c0a..bc35b8b61 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivityType.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardActivityType.java @@ -35,22 +35,31 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; -public class StandardActivityType> extends SimpleActivity implements ActivityType { +public class StandardActivityType> implements ActivityType { private static final Logger logger = LogManager.getLogger("ACTIVITY"); private final Map adapters = new HashMap<>(); + private final NBComponent parent; +// private final DriverAdapter adapter; + private final ActivityDef activityDef; public StandardActivityType(final DriverAdapter adapter, final ActivityDef activityDef, final NBComponent parent) { - super(parent,activityDef - .deprecate("type","driver") - .deprecate("yaml", "workload") - ); + this.parent = parent; +// this.adapter = adapter; + this.activityDef = activityDef; +// super(parent,activityDef +// .deprecate("type","driver") +// .deprecate("yaml", "workload") +// ); adapters.put(adapter.getAdapterName(),adapter); if (adapter instanceof ActivityDefAware) ((ActivityDefAware) adapter).setActivityDef(activityDef); } public StandardActivityType(final ActivityDef activityDef, final NBComponent parent) { - super(parent,activityDef); + this.parent = parent; + this.activityDef = activityDef; + +// super(parent,activityDef); } @Override @@ -61,33 +70,10 @@ public class StandardActivityType> extends Simpl return (A) new StandardActivity(parent, activityDef); } - @Override - public synchronized void onActivityDefUpdate(final ActivityDef activityDef) { - super.onActivityDefUpdate(activityDef); - - for (final DriverAdapter adapter : this.adapters.values()) - if (adapter instanceof NBReconfigurable reconfigurable) { - NBConfigModel cfgModel = reconfigurable.getReconfigModel(); - final Optional op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload"); - if (op_yaml_loc.isPresent()) { - final Map disposable = new LinkedHashMap<>(activityDef.getParams()); - final OpsDocList workload = OpsLoader.loadPath(op_yaml_loc.get(), disposable, "activities"); - cfgModel = cfgModel.add(workload.getConfigModel()); - } - final NBConfiguration cfg = cfgModel.apply(activityDef.getParams()); - reconfigurable.applyReconfig(cfg); - } - - } @Override public ActionDispenser getActionDispenser(final A activity) { return new StandardActionDispenser(activity); } - - @Override - public void shutdownActivity() { - - } } diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/scenarios/NBCLIScenarioParser.java b/engine-api/src/main/java/io/nosqlbench/engine/api/scenarios/NBCLIScenarioParser.java index 711d39169..25606d455 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/scenarios/NBCLIScenarioParser.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/scenarios/NBCLIScenarioParser.java @@ -219,6 +219,12 @@ public class NBCLIScenarioParser { if (!shortened.equals(sanitized)) { logger.warn("The identifier or value '" + shortened + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier."); + StackTraceElement[] elements = Thread.currentThread().getStackTrace(); + StringBuilder stb = new StringBuilder(); + for (StackTraceElement element : elements) { + stb.append("\tat ").append(element).append("\n"); + } + logger.warn("stacktrace: " + stb.toString()); } return sanitized; } diff --git a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/activity/ActivityExecutor.java b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/activity/ActivityExecutor.java index 0275d7845..f44515f5a 100644 --- a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/activity/ActivityExecutor.java +++ b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/activity/ActivityExecutor.java @@ -413,6 +413,8 @@ public class ActivityExecutor implements NBLabeledElement, ParameterMap.Listener finish(true); return result; } + } catch (Exception e2) { + throw new RuntimeException(e2); } } @@ -426,6 +428,9 @@ public class ActivityExecutor implements NBLabeledElement, ParameterMap.Listener * has been completed at least. */ private void awaitMotorsAtLeastRunning() { + if (this.exception!=null) { + return; + } RunStateImage states = tally.awaitAny(RunState.Running, RunState.Stopped, RunState.Finished, RunState.Errored); RunState maxState = states.getMaxState(); if (maxState == RunState.Errored) { @@ -489,7 +494,7 @@ public class ActivityExecutor implements NBLabeledElement, ParameterMap.Listener RunState maxState = state.getMaxState(); activity.setRunState(maxState); if (maxState == RunState.Errored) { - throw new RuntimeException("Error while waiting for activity completion:" + this.exception); + throw new RuntimeException("Error while waiting for activity completion" + (this.exception!=null ? this.exception.toString() : "")); } } diff --git a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/context/ScenarioActivitiesController.java b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/context/ScenarioActivitiesController.java index 1c205980f..755cb5bcd 100644 --- a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/context/ScenarioActivitiesController.java +++ b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/context/ScenarioActivitiesController.java @@ -75,6 +75,7 @@ public class ScenarioActivitiesController extends NBBaseComponent { private ActivityRuntimeInfo doStartActivity(ActivityDef activityDef) { if (!this.activityInfoMap.containsKey(activityDef.getAlias())) { Activity activity = this.activityLoader.loadActivity(activityDef, this); + activity.initActivity(); ActivityExecutor executor = new ActivityExecutor(activity); Future startedActivity = executorService.submit(executor); ActivityRuntimeInfo activityRuntimeInfo = new ActivityRuntimeInfo(activity, startedActivity, executor); diff --git a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/execution/ScenariosExecutor.java b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/execution/ScenariosExecutor.java index 995877d87..d20922e1f 100644 --- a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/execution/ScenariosExecutor.java +++ b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/scenario/execution/ScenariosExecutor.java @@ -85,7 +85,7 @@ public class ScenariosExecutor extends NBBaseComponent { * @return the final scenario-result map. */ public ScenariosResults awaitAllResults() { - return awaitAllResults(Long.MAX_VALUE / 2, 60000); // half max value, to avoid overflow + return awaitAllResults(Long.MAX_VALUE / 2, 10000); // half max value, to avoid overflow } /** @@ -103,30 +103,40 @@ public class ScenariosExecutor extends NBBaseComponent { long timeoutAt = System.currentTimeMillis() + timeout; executor.shutdown(); - boolean isShutdown = false; - - while (!isShutdown && System.currentTimeMillis() < timeoutAt) { - long waitedAt = System.currentTimeMillis(); - long updateAt = Math.min(timeoutAt, waitedAt + updateInterval); - while (!isShutdown && System.currentTimeMillis() < timeoutAt) { - while (!isShutdown && System.currentTimeMillis() < updateAt) { - try { - long timeRemaining = updateAt - System.currentTimeMillis(); - isShutdown = executor.awaitTermination(timeRemaining, TimeUnit.MILLISECONDS); - } catch (InterruptedException ignored) { - } + try { + while (!executor.awaitTermination(timeout, TimeUnit.MILLISECONDS)) { + if (System.currentTimeMillis()>=timeoutAt) { + throw new RuntimeException("executor still running scenarios after awaiting all results for " + timeout + + "ms. isTerminated:" + executor.isTerminated() + " isShutdown:" + executor.isShutdown()); } - logger.trace(() -> "waited " + (System.currentTimeMillis()-waitFrom) + " millis for scenarios"); - updateAt = Math.min(timeoutAt, System.currentTimeMillis() + updateInterval); } - - logger.debug("scenarios executor shutdown after " + (System.currentTimeMillis() - waitedAt) + "ms."); + } catch (InterruptedException ignored) { } - if (!isShutdown) { - throw new RuntimeException("executor still runningScenarios after awaiting all results for " + timeout - + "ms. isTerminated:" + executor.isTerminated() + " isShutdown:" + executor.isShutdown()); - } +// while (!executor.isShutdown() && System.currentTimeMillis() < timeoutAt) { +// long waitedAt = System.currentTimeMillis(); +// long updateAt = Math.min(timeoutAt, waitedAt + updateInterval); +// while (!executor.isShutdown() && System.currentTimeMillis() < timeoutAt) { +// while (!executor.isShutdown() && System.currentTimeMillis() < updateAt) { +// try { +// long timeRemaining = updateAt - System.currentTimeMillis(); +// if (executor.awaitTermination(timeRemaining, TimeUnit.MILLISECONDS)) { +// logger.info("executor shutdown during await"); +// } +// } catch (InterruptedException ignored) { +// } +// } +// logger.trace(() -> "waited " + (System.currentTimeMillis()-waitFrom) + " millis for scenarios"); +// updateAt = Math.min(timeoutAt, System.currentTimeMillis() + updateInterval); +// } +// +// logger.debug("scenarios executor shutdown after " + (System.currentTimeMillis() - waitedAt) + "ms."); +// } +// +// if (!executor.isShutdown()) { +// throw new RuntimeException("executor still runningScenarios after awaiting all results for " + timeout +// + "ms. isTerminated:" + executor.isTerminated() + " isShutdown:" + executor.isShutdown()); +// } Map scenarioResultMap = new LinkedHashMap<>(); getAsyncResultStatus() .entrySet() diff --git a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/session/NBSession.java b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/session/NBSession.java index 503282024..bf14c2b3f 100644 --- a/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/session/NBSession.java +++ b/engine-core/src/main/java/io/nosqlbench/engine/core/lifecycle/session/NBSession.java @@ -100,6 +100,8 @@ public class NBSession extends NBBaseComponent implements Function, Ex try (NBComponentSubScope scope = new NBComponentSubScope(scenario)) { scenariosExecutor.execute(scenario, params); // this.doReportSummaries(this.reportSummaryTo, this.result); + } catch (Exception e) { + results.error(e); } final ScenariosResults scenariosResults = scenariosExecutor.awaitAllResults(); logger.debug(() -> "Total of " + scenariosResults.getSize() + " result object returned from ScenariosExecutor"); diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml index 4d730e13e..b6cd8b1d2 100644 --- a/mvn-defaults/pom.xml +++ b/mvn-defaults/pom.xml @@ -361,29 +361,29 @@ org.graalvm.sdk graal-sdk - 22.3.3 + 23.0.1 org.graalvm.js js - 22.3.3 + 23.0.1 runtime org.graalvm.js js-scriptengine - 23.1.0 + 23.0.1 org.graalvm.tools profiler - 22.3.3 + 23.0.1 runtime org.graalvm.tools chromeinspector - 21.2.0 + 23.0.1 runtime diff --git a/nb-api/src/main/java/io/nosqlbench/api/engine/metrics/reporters/PromExpositionFormat.java b/nb-api/src/main/java/io/nosqlbench/api/engine/metrics/reporters/PromExpositionFormat.java index ca3d19608..3dd36dce8 100644 --- a/nb-api/src/main/java/io/nosqlbench/api/engine/metrics/reporters/PromExpositionFormat.java +++ b/nb-api/src/main/java/io/nosqlbench/api/engine/metrics/reporters/PromExpositionFormat.java @@ -235,6 +235,13 @@ public class PromExpositionFormat { if (!word.equals(sanitized)) { logger.warn("The identifier or value '" + word + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier."); + StackTraceElement[] elements = Thread.currentThread().getStackTrace(); + StringBuilder stb = new StringBuilder(); + for (StackTraceElement element : elements) { + stb.append("\tat ").append(element).append("\n"); + } + logger.warn("stacktrace: " + stb.toString()); + } return sanitized; } diff --git a/nb-api/src/main/java/io/nosqlbench/components/NBBaseComponent.java b/nb-api/src/main/java/io/nosqlbench/components/NBBaseComponent.java index 299d2e393..0abc57e7d 100644 --- a/nb-api/src/main/java/io/nosqlbench/components/NBBaseComponent.java +++ b/nb-api/src/main/java/io/nosqlbench/components/NBBaseComponent.java @@ -60,8 +60,8 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone for (NBComponent extant : this.children) { if (!child.getComponentOnlyLabels().isEmpty() && child.getComponentOnlyLabels().equals(extant.getComponentOnlyLabels())) { throw new RuntimeException("Adding second child under already-defined labels is not allowed:\n" + - " extant: " + extant + "\n" + - " adding: " + child); + " extant: (" + extant.getClass().getSimpleName() + ") " + extant.description() + "\n" + + " adding: (" + child.getClass().getSimpleName() + ") " + child.description()); } } diff --git a/nb_521.md b/nb_521.md index 374de3d51..d23a13be0 100644 --- a/nb_521.md +++ b/nb_521.md @@ -155,5 +155,3 @@ control of all data flows. (Yes you could use the external gateway, but that was part.) This further degraded the quality of metrics data by taking the timing and cadence of metrics flows out of control of the client. It also put metrics flow behind two uncoordinated polling mechanisms which degraded the immediacy of the metrics. - -