allow dryrun to be multi-modal

This commit is contained in:
Jonathan Shook 2023-02-05 20:29:52 -06:00
parent 4f827c8031
commit 4e70eb7680
3 changed files with 45 additions and 44 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022 nosqlbench * Copyright (c) 2022-2023 nosqlbench
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -166,7 +166,7 @@ public abstract class BaseDriverAdapter<R extends Op, S> implements DriverAdapte
.add(Param.optional("instrument", Boolean.class)) .add(Param.optional("instrument", Boolean.class))
.add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file")) .add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file"))
.add(Param.optional("driver", String.class)) .add(Param.optional("driver", String.class))
.add(Param.defaultTo("dryrun",false)) .add(Param.defaultTo("dryrun","none").setRegex("(op|jsonnet|none)"))
.asReadOnly(); .asReadOnly();
} }

View File

@ -495,7 +495,8 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
logger.info(() -> "skipped mapping op '" + pop.getName() + "'"); logger.info(() -> "skipped mapping op '" + pop.getName() + "'");
continue; continue;
} }
boolean dryrun = pop.takeStaticConfigOr("dryrun", false); String dryrunSpec = pop.takeStaticConfigOr("dryrun", "none");
boolean dryrun = dryrunSpec.equalsIgnoreCase("op");
DriverAdapter adapter = adapters.get(i); DriverAdapter adapter = adapters.get(i);
OpMapper opMapper = adapter.getOpMapper(); OpMapper opMapper = adapter.getOpMapper();

View File

@ -82,7 +82,7 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
/** /**
* Simply stop the motors * Simply stop the motors
*/ */
public void stopActivity() { public void stopActivity() {
logger.info(() -> "stopping activity in progress: " + this.getActivityDef().getAlias()); logger.info(() -> "stopping activity in progress: " + this.getActivityDef().getAlias());
activity.setRunState(RunState.Stopping); activity.setRunState(RunState.Stopping);
@ -96,14 +96,14 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
logger.info(() -> "stopped: " + this.getActivityDef().getAlias() + " with " + motors.size() + " slots"); logger.info(() -> "stopped: " + this.getActivityDef().getAlias() + " with " + motors.size() + " slots");
Annotators.recordAnnotation(Annotation.newBuilder() Annotators.recordAnnotation(Annotation.newBuilder()
.session(sessionId) .session(sessionId)
.interval(this.startedAt, this.stoppedAt) .interval(this.startedAt, this.stoppedAt)
.layer(Layer.Activity) .layer(Layer.Activity)
.label("alias", getActivityDef().getAlias()) .label("alias", getActivityDef().getAlias())
.label("driver", getActivityDef().getActivityType()) .label("driver", getActivityDef().getActivityType())
.label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none")) .label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none"))
.detail("params", getActivityDef().toString()) .detail("params", getActivityDef().toString())
.build() .build()
); );
} }
@ -123,14 +123,14 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
logger.info(() -> "stopped: " + this.getActivityDef().getAlias() + " with " + motors.size() + " slots"); logger.info(() -> "stopped: " + this.getActivityDef().getAlias() + " with " + motors.size() + " slots");
Annotators.recordAnnotation(Annotation.newBuilder() Annotators.recordAnnotation(Annotation.newBuilder()
.session(sessionId) .session(sessionId)
.interval(this.startedAt, this.stoppedAt) .interval(this.startedAt, this.stoppedAt)
.layer(Layer.Activity) .layer(Layer.Activity)
.label("alias", getActivityDef().getAlias()) .label("alias", getActivityDef().getAlias())
.label("driver", getActivityDef().getActivityType()) .label("driver", getActivityDef().getActivityType())
.label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none")) .label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none"))
.detail("params", getActivityDef().toString()) .detail("params", getActivityDef().toString())
.build() .build()
); );
} }
@ -210,10 +210,10 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
adjustMotorCountToThreadParam(activity.getActivityDef()); adjustMotorCountToThreadParam(activity.getActivityDef());
} }
motors.stream() motors.stream()
.filter(m -> (m instanceof ActivityDefObserver)) .filter(m -> (m instanceof ActivityDefObserver))
// .filter(m -> m.getSlotStateTracker().getSlotState() != RunState.Uninitialized) // .filter(m -> m.getSlotStateTracker().getSlotState() != RunState.Uninitialized)
// .filter(m -> m.getSlotStateTracker().getSlotState() != RunState.Starting) // .filter(m -> m.getSlotStateTracker().getSlotState() != RunState.Starting)
.forEach(m -> ((ActivityDefObserver) m).onActivityDefUpdate(activityDef)); .forEach(m -> ((ActivityDefObserver) m).onActivityDefUpdate(activityDef));
} }
} }
@ -227,8 +227,8 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
private String getSlotStatus() { private String getSlotStatus() {
return motors.stream() return motors.stream()
.map(m -> m.getState().get().getCode()) .map(m -> m.getState().get().getCode())
.collect(Collectors.joining(",", "[", "]")); .collect(Collectors.joining(",", "[", "]"));
} }
/** /**
@ -285,17 +285,17 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
case Running: case Running:
case Starting: case Starting:
motors.stream() motors.stream()
.filter(m -> m.getState().get() != RunState.Running) .filter(m -> m.getState().get() != RunState.Running)
.filter(m -> m.getState().get() != RunState.Finished) .filter(m -> m.getState().get() != RunState.Finished)
.filter(m -> m.getState().get() != RunState.Starting) .filter(m -> m.getState().get() != RunState.Starting)
.forEach(m -> { .forEach(m -> {
executorService.execute(m); executorService.execute(m);
}); });
break; break;
case Stopped: case Stopped:
motors.stream() motors.stream()
.filter(m -> m.getState().get() != RunState.Stopped) .filter(m -> m.getState().get() != RunState.Stopped)
.forEach(Motor::requestStop); .forEach(Motor::requestStop);
break; break;
case Finished: case Finished:
case Stopping: case Stopping:
@ -474,10 +474,10 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
private void startMotorExecutorService() { private void startMotorExecutorService() {
this.executorService = new ThreadPoolExecutor( this.executorService = new ThreadPoolExecutor(
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,
0L, TimeUnit.SECONDS, 0L, TimeUnit.SECONDS,
new SynchronousQueue<>(), new SynchronousQueue<>(),
new IndexedThreadFactory(activity.getAlias(), new ActivityExceptionHandler(this)) new IndexedThreadFactory(activity.getAlias(), new ActivityExceptionHandler(this))
); );
} }
@ -494,14 +494,14 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
logger.info(() -> "starting activity " + activity.getAlias() + " for cycles " + activity.getCycleSummary()); logger.info(() -> "starting activity " + activity.getAlias() + " for cycles " + activity.getCycleSummary());
Annotators.recordAnnotation(Annotation.newBuilder() Annotators.recordAnnotation(Annotation.newBuilder()
.session(sessionId) .session(sessionId)
.now() .now()
.layer(Layer.Activity) .layer(Layer.Activity)
.label("alias", getActivityDef().getAlias()) .label("alias", getActivityDef().getAlias())
.label("driver", getActivityDef().getActivityType()) .label("driver", getActivityDef().getActivityType())
.label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none")) .label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none"))
.detail("params", getActivityDef().toString()) .detail("params", getActivityDef().toString())
.build() .build()
); );
activitylogger.debug("START/before alias=(" + activity.getAlias() + ")"); activitylogger.debug("START/before alias=(" + activity.getAlias() + ")");