Class Operator.OperatorThread

java.lang.Object
java.lang.Thread
com.streambase.sb.operator.Operator.OperatorThread
All Implemented Interfaces:
Runnable
Enclosing class:
Operator

public class Operator.OperatorThread extends Thread
The thread that wraps an operator runnable
  • Constructor Details

    • OperatorThread

      OperatorThread(String name, Runnable operatorRunnable, boolean shouldInterrupt, boolean synchronizedShutdown)
      Constructor
      Parameters:
      name - Thread name
      operatorRunnable - Runnable
      shouldInterrupt - Should interrupt?
      synchronizedShutdown - Synchronized shutdown?
  • Method Details

    • run

      public void run()
      Run method of this operator thread. This starts the operator runnable's run method and, upon exit, either accepts the SHUTDOWN state request, or goes silently.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • shouldInterrupt

      boolean shouldInterrupt()
      Get should interrupt?
      Returns:
      true to interrupt, false otherwise
    • shouldRun

      public boolean shouldRun()
      Implement state request responses of this operator thread.
      Returns:
      true to run, false otherwise
    • getNextState

      int getNextState()
      Get next state
      Returns:
      State
    • postStateChange

      void postStateChange(int state)
      Request that the operator thread switch into a new state.

      waitForAcceptance() must be called before another state change can be posted.

      This method must be called from the main thread.

      Parameters:
      state - New state
    • waitForAcceptance

      void waitForAcceptance() throws StreamBaseException
      Block until the operator thread has successfully switched into the new state requested by postStateChange.

      This must be must be called from the main thread.

      Throws:
      StreamBaseException - If timed out.
    • shutdown

      void shutdown()
      Explicitly set the state of the thread to shutdown. Used only when the Operator fails.