Class Operator.OperatorStates
- java.lang.Object
-
- com.streambase.sb.operator.Operator.OperatorStates
-
- Enclosing class:
- Operator
public static class Operator.OperatorStates extends Object
The set of runtime states that an Operator can be in. The state of an Operator may change along with the state of the StreamBase application that holds its instance.The state of a given Operator may also be changed independently of its application through
epadmin.Informally, an Operator transitions through states as follows. The initial state of an Operator is
NOT_YET_STARTED. In this state an Operator has been instantiated and itsinit()method has been called.From
NOT_YET_STARTEDan Operator transitions to theSTARTEDstate. An Operator starts either because its containing application has started or because it has been started throughepadmin. An Operator receives two callbacks from the StreamBase runtime when it starts,resume()andresumed(). First, the runtime calls theresume()method. Onceresume()has returned, any threads that the Operator has registered are started, if need be. Next, the Operator transitions to theSTARTEDstate. The Operator then receives a second callback,resumed().From the
STARTEDstate, the Operator may transition to theSUSPENDEDstate. An Operator may transition toSUSPENDEDbecause its application has suspended or because it has been explicitly suspended withepadmin. The StreamBase runtime also makes call backs on suspend; first thesuspend()callback is made, then the Operator transitions to theSUSPENDEDstate, then thesuspended()callback is made.From
SUSPENDED, an Operator can transition back toSTARTED. This is referred to as 'resuming'. An Operator can resume when its application resumes or when it is explicitly resumed throughepadmin.An Operator get the same callbacks from the runtime when it starts and when it resumes,
resume()andresumed(). Essentially then, these two transitions, starting and resuming, are equivalent. This implies then that any code that should be run just once for an instance of an Operator belongs in itsinit()method, rather than in theresume()orresumed()methods.An Operator can transition between
STARTEDandSUSPENDEDany number of times.SHUTDOWNis an Operator's terminal state. An Operator can enter theSHUTDOWNstate from any of its other states. The StreamBase runtime calls back to the methodshutdownprior to enteringSHUTDOWN.An instance of an Operator can not be recovered from a state of
SHUTDOWN. Once shut down, an Operator can be 'restarted' using theepadminstart command. However, this causes a new Operator instance to be constructed and itsinit()method to be called. Any state held by the prior instance of the Operator is lost.
-
-
Field Summary
Fields Modifier and Type Field Description static intINITIALIZEDThe initial state of an Operator.static intNONEInvalid operator statestatic intSHUTDOWNThe terminal state of the Operator.static intSTARTEDThe Operator has been started; resume() has been called.static intSUSPENDEDThe Operator has been suspended; suspend() has been called.
-
-
-
Field Detail
-
NONE
public static final int NONE
Invalid operator state- See Also:
- Constant Field Values
-
INITIALIZED
public static final int INITIALIZED
The initial state of an Operator. init() has been called, but not resume()- See Also:
- Constant Field Values
-
STARTED
public static final int STARTED
The Operator has been started; resume() has been called.- See Also:
- Constant Field Values
-
SUSPENDED
public static final int SUSPENDED
The Operator has been suspended; suspend() has been called.- See Also:
- Constant Field Values
-
SHUTDOWN
public static final int SHUTDOWN
The terminal state of the Operator. Once shutdown, an Operator can no longer be accessed. It can be restarted, which causes the Operator to be reinstantiated and reinitialized (init() called).- See Also:
- Constant Field Values
-
-