Class CoreMotor<D>

java.lang.Object
io.nosqlbench.engine.api.activityimpl.motor.CoreMotor<D>
All Implemented Interfaces:
ActivityDefObserver, Motor<D>, Stoppable, Runnable

public class CoreMotor<D> extends Object implements ActivityDefObserver, Motor<D>, Stoppable
ActivityMotor is a Runnable which runs in one of an activity's many threads. It is the iteration harness for individual cycles of an activity. Each ActivityMotor instance is responsible for taking input from a LongSupplier and applying the provided LongConsumer to it on each cycle. These two parameters are called input and action, respectively. This motor implementation splits the handling of sync and async actions with a hard fork in the middle to limit potential breakage of the prior sync implementation with new async logic.
  • Constructor Details

    • CoreMotor

      public CoreMotor(Activity activity, long slotId, Input input)
      Create an ActivityMotor.
      Parameters:
      activity - The activity that this motor will be associated with.
      slotId - The enumeration of the motor, as assigned by its executor.
      input - A LongSupplier which provides the cycle number inputs.
    • CoreMotor

      public CoreMotor(Activity activity, long slotId, Input input, Action action)
      Create an ActivityMotor.
      Parameters:
      activity - The activity that this motor is based on.
      slotId - The enumeration of the motor, as assigned by its executor.
      input - A LongSupplier which provides the cycle number inputs.
      action - An LongConsumer which is applied to the input for each cycle.
    • CoreMotor

      public CoreMotor(Activity activity, long slotId, Input input, Action action, Output output)
      Create an ActivityMotor.
      Parameters:
      activity - The activity that this motor is based on.
      slotId - The enumeration of the motor, as assigned by its executor.
      input - A LongSupplier which provides the cycle number inputs.
      action - An LongConsumer which is applied to the input for each cycle.
      output - An optional opTracker.
  • Method Details

    • setInput

      public Motor<D> setInput(Input input)
      Set the input for this ActivityMotor.
      Specified by:
      setInput in interface Motor<D>
      Parameters:
      input - The LongSupplier that provides the cycle number.
      Returns:
      this ActivityMotor, for chaining
    • getInput

      public Input getInput()
      Specified by:
      getInput in interface Motor<D>
    • setAction

      public Motor<D> setAction(Action action)
      Set the action for this ActivityMotor.
      Specified by:
      setAction in interface Motor<D>
      Parameters:
      action - The LongConsumer that will be applied to the next cycle number.
      Returns:
      this ActivityMotor, for chaining
    • getAction

      public Action getAction()
      Specified by:
      getAction in interface Motor<D>
    • getSlotId

      public long getSlotId()
      Description copied from interface: Motor
      get the slotId which this motor is assigned to within the activity instance.
      Specified by:
      getSlotId in interface Motor<D>
      Returns:
      long slot id
    • getState

      public MotorState getState()
      Description copied from interface: Motor
      Get a description of the current slot run status.
      Specified by:
      getState in interface Motor<D>
      Returns:
      - a value from the RunState enum
    • removeState

      public void removeState()
      Specified by:
      removeState in interface Motor<D>
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • toString

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

      public void onActivityDefUpdate(ActivityDef activityDef)
      Specified by:
      onActivityDefUpdate in interface ActivityDefObserver
    • requestStop

      public void requestStop()
      Description copied from interface: Stoppable
      Ask this component to stop cycling. This is an asynchronous request. Once the current active cycle completes, the request will cause the component to stop cooperatively.
      Specified by:
      requestStop in interface Stoppable
    • setResultOutput

      public void setResultOutput(Output resultOutput)