Class ActivityExecutor

java.lang.Object
io.nosqlbench.engine.core.ActivityExecutor
All Implemented Interfaces:
io.nosqlbench.engine.api.activityapi.core.ActivityController, io.nosqlbench.engine.api.activityapi.core.ProgressMeter, io.nosqlbench.engine.api.activityimpl.ParameterMap.Listener

public class ActivityExecutor
extends java.lang.Object
implements io.nosqlbench.engine.api.activityapi.core.ActivityController, io.nosqlbench.engine.api.activityimpl.ParameterMap.Listener, io.nosqlbench.engine.api.activityapi.core.ProgressMeter

An ActivityExecutor is a named instance of 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.

An ActivityExecutor may be represent an activity that is defined and active in the running scenario, but which is inactive. This can occur when an activity is paused by controlling logic, or when the threads are set to zero.

Invariants:

  • Motors may not receive parameter updates before their owning activities are initialized.
  • Constructor Summary

    Constructors 
    Constructor Description
    ActivityExecutor​(io.nosqlbench.engine.api.activityapi.core.Activity activity)  
  • Method Summary

    Modifier and Type Method Description
    boolean awaitCompletion​(int waitTime)  
    boolean awaitFinish​(int timeout)  
    void forceStopExecutor​(int initialMillisToWait)
    Shutdown the activity executor, with a grace period for the motor threads.
    io.nosqlbench.engine.api.activityapi.core.Activity getActivity()  
    io.nosqlbench.engine.api.activityimpl.ActivityDef getActivityDef()  
    double getProgress()  
    java.lang.String getProgressDetails()  
    java.lang.String getProgressName()  
    io.nosqlbench.engine.api.activityapi.core.RunState getProgressState()  
    void handleParameterMapUpdate​(io.nosqlbench.engine.api.activityimpl.ParameterMap parameterMap)
    Listens for changes to parameter maps, maps them to the activity instance, and notifies all eligible listeners of changes.
    boolean isRunning()  
    void notifyException​(java.lang.Thread t, java.lang.Throwable e)  
    boolean requestStopExecutor​(int secondsToWait)  
    void startActivity()
    True-up the number of motor instances known to the executor.
    void stopActivity()
    Simply stop the motors
    void stopActivityWithErrorAsync​(java.lang.Throwable throwable)  
    void stopActivityWithReasonAsync​(java.lang.String reason)  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ActivityExecutor

      public ActivityExecutor​(io.nosqlbench.engine.api.activityapi.core.Activity activity)
  • Method Details

    • startActivity

      public void startActivity()

      True-up the number of motor instances known to the executor. Start all non-running motors. The protocol between the motors and the executor should be safe as long as each state change is owned by either the motor logic or the activity executor but not both, and strictly serialized as well. This is enforced by forcing start(...) to be serialized as well as using CAS on the motor states.

      The startActivity method may be called to true-up the number of active motors in an activity executor after changes to threads.

    • stopActivity

      public void stopActivity()
      Simply stop the motors
    • forceStopExecutor

      public void forceStopExecutor​(int initialMillisToWait)
      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
    • requestStopExecutor

      public boolean requestStopExecutor​(int secondsToWait)
    • handleParameterMapUpdate

      public void handleParameterMapUpdate​(io.nosqlbench.engine.api.activityimpl.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 io.nosqlbench.engine.api.activityimpl.ParameterMap.Listener
    • getActivityDef

      public io.nosqlbench.engine.api.activityimpl.ActivityDef getActivityDef()
    • awaitCompletion

      public boolean awaitCompletion​(int waitTime)
    • awaitFinish

      public boolean awaitFinish​(int timeout)
    • toString

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

      public boolean isRunning()
    • getActivity

      public io.nosqlbench.engine.api.activityapi.core.Activity getActivity()
    • getProgress

      public double getProgress()
      Specified by:
      getProgress in interface io.nosqlbench.engine.api.activityapi.core.ProgressMeter
    • getProgressDetails

      public java.lang.String getProgressDetails()
      Specified by:
      getProgressDetails in interface io.nosqlbench.engine.api.activityapi.core.ProgressMeter
    • getProgressName

      public java.lang.String getProgressName()
      Specified by:
      getProgressName in interface io.nosqlbench.engine.api.activityapi.core.ProgressMeter
    • getProgressState

      public io.nosqlbench.engine.api.activityapi.core.RunState getProgressState()
      Specified by:
      getProgressState in interface io.nosqlbench.engine.api.activityapi.core.ProgressMeter
    • notifyException

      public void notifyException​(java.lang.Thread t, java.lang.Throwable e)
    • stopActivityWithReasonAsync

      public void stopActivityWithReasonAsync​(java.lang.String reason)
      Specified by:
      stopActivityWithReasonAsync in interface io.nosqlbench.engine.api.activityapi.core.ActivityController
    • stopActivityWithErrorAsync

      public void stopActivityWithErrorAsync​(java.lang.Throwable throwable)
      Specified by:
      stopActivityWithErrorAsync in interface io.nosqlbench.engine.api.activityapi.core.ActivityController