Class 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 its init() method has been called.

    From NOT_YET_STARTED an Operator transitions to the STARTED state. An Operator starts either because its containing application has started or because it has been started through epadmin. An Operator receives two callbacks from the StreamBase runtime when it starts, resume() and resumed(). First, the runtime calls the resume() method. Once resume() has returned, any threads that the Operator has registered are started, if need be. Next, the Operator transitions to the STARTED state. The Operator then receives a second callback, resumed().

    From the STARTED state, the Operator may transition to the SUSPENDED state. An Operator may transition to SUSPENDED because its application has suspended or because it has been explicitly suspended with epadmin. The StreamBase runtime also makes call backs on suspend; first the suspend() callback is made, then the Operator transitions to the SUSPENDED state, then the suspended() callback is made.

    From SUSPENDED, an Operator can transition back to STARTED. This is referred to as 'resuming'. An Operator can resume when its application resumes or when it is explicitly resumed through epadmin.

    An Operator get the same callbacks from the runtime when it starts and when it resumes, resume() and resumed(). 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 its init() method, rather than in the resume() or resumed() methods.

    An Operator can transition between STARTED and SUSPENDED any number of times.

    SHUTDOWN is an Operator's terminal state. An Operator can enter the SHUTDOWN state from any of its other states. The StreamBase runtime calls back to the method shutdown prior to entering SHUTDOWN.

    An instance of an Operator can not be recovered from a state of SHUTDOWN. Once shut down, an Operator can be 'restarted' using the epadmin start command. However, this causes a new Operator instance to be constructed and its init() method to be called. Any state held by the prior instance of the Operator is lost.

    • Field Detail

      • 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