Package com.streambase.sb.operator
Class Operator.OperatorThread
java.lang.Object
java.lang.Thread
com.streambase.sb.operator.Operator.OperatorThread
- All Implemented Interfaces:
Runnable
- Enclosing class:
- Operator
The thread that wraps an operator runnable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionOperatorThread
(String name, Runnable operatorRunnable, boolean shouldInterrupt, boolean synchronizedShutdown) Constructor -
Method Summary
Modifier and TypeMethodDescription(package private) int
Get next state(package private) void
postStateChange
(int state) Request that the operator thread switch into a new state.void
run()
Run method of this operator thread.(package private) boolean
Get should interrupt?boolean
Implement state request responses of this operator thread.(package private) void
shutdown()
Explicitly set the state of the thread to shutdown.(package private) void
Block until the operator thread has successfully switched into the new state requested by postStateChange.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
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. -
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
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.
-