Class ActivityExecutor
- All Implemented Interfaces:
ProgressCapable,ParameterMap.Listener,NBLabeledElement,Callable<ExecutionResult>
An ActivityExecutor is an execution harness for a single activity instance. It is responsible for managing threads and activity settings which may be changed while the activity is running.
In order to allow for dynamic thread management, which is not easily supported as an explicit feature
of most executor services, threads are started as long-running processes and managed via state signaling.
The RunState enum, MotorState type, and RunStateTally
state tracking class are used together to represent valid states and transitions, contain and transition state
atomically,
and provide blocking conditions for observers, respectively.
Some basic rules and invariants must be observed for consistent concurrent behavior.
Any state changes for a Motor must be made through Motor.getState().
This allows the state tracking to work consistently for all observers.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
NBLabeledElement.BasicLabeledElement -
Field Summary
Fields inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitAllThreadsOnline(long timeoutMs) voidcall()voidfinish(boolean graceful) voidForce stop the motors without trying to wait for the activity to reach stopped/finished stateforceStopActivity(int initialMillisToWait) voidforceStopScenarioAndThrow(int initialMillisToWait, boolean rethrow) Shutdown the activity executor, with a grace period for the motor threads.voidhandleParameterMapUpdate(ParameterMap parameterMap) Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of changes.booleanvoidnotifyException(Thread t, Throwable e) voidSimply stop the motorstoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
description
-
Constructor Details
-
ActivityExecutor
-
-
Method Details
-
stopActivity
public void stopActivity()Simply stop the motors -
forceStopActivity
public void forceStopActivity()Force stop the motors without trying to wait for the activity to reach stopped/finished state -
forceStopActivity
-
forceStopScenarioAndThrow
public void forceStopScenarioAndThrow(int initialMillisToWait, boolean rethrow) Shutdown the activity executor, with a grace period for the motor threads.- Parameters:
initialMillisToWait- milliseconds to wait after graceful shutdownActivity request, before forcing everything to stop
-
handleParameterMapUpdate
Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of changes.- Specified by:
handleParameterMapUpdatein interfaceParameterMap.Listener
-
getActivityDef
-
toString
-
isRunning
public boolean isRunning() -
getActivity
-
notifyException
-
getProgressMeter
- Specified by:
getProgressMeterin interfaceProgressCapable
-
call
- Specified by:
callin interfaceCallable<ExecutionResult>- Throws:
Exception
-
getLabels
- Specified by:
getLabelsin interfaceNBLabeledElement
-
finish
public void finish(boolean graceful) -
awaitMotorsRunningOrTerminalState
public void awaitMotorsRunningOrTerminalState() -
awaitAllThreadsOnline
public boolean awaitAllThreadsOnline(long timeoutMs)
-