Class ActivityExecutor

java.lang.Object
io.nosqlbench.engine.core.lifecycle.activity.ActivityExecutor
All Implemented Interfaces:
ProgressCapable, ParameterMap.Listener, NBLabeledElement, Callable<ExecutionResult>

public class ActivityExecutor extends Object implements NBLabeledElement, ParameterMap.Listener, ProgressCapable, 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.

  • Constructor Details

    • ActivityExecutor

      public ActivityExecutor(Activity activity)
  • 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

      public Exception forceStopActivity(int initialMillisToWait)
    • 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

      public void handleParameterMapUpdate(ParameterMap parameterMap)
      Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of changes.
      Specified by:
      handleParameterMapUpdate in interface ParameterMap.Listener
    • getActivityDef

      public ActivityDef getActivityDef()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isRunning

      public boolean isRunning()
    • getActivity

      public Activity getActivity()
    • notifyException

      public void notifyException(Thread t, Throwable e)
    • getProgressMeter

      public ProgressMeterDisplay getProgressMeter()
      Specified by:
      getProgressMeter in interface ProgressCapable
    • call

      public ExecutionResult call() throws Exception
      Specified by:
      call in interface Callable<ExecutionResult>
      Throws:
      Exception
    • getLabels

      public NBLabels getLabels()
      Specified by:
      getLabels in interface NBLabeledElement
    • finish

      public void finish(boolean graceful)
    • awaitMotorsRunningOrTerminalState

      public void awaitMotorsRunningOrTerminalState()
    • awaitAllThreadsOnline

      public boolean awaitAllThreadsOnline(long timeoutMs)