Listens to an operator/selector and reports its state and activity to a GracefulShutdownMonitor, shared with other listeners.
Modifiers | Name | Description |
---|---|---|
private java.util.concurrent.atomic.AtomicInteger |
activeForks |
|
private boolean |
collectingMessages |
|
private java.util.concurrent.atomic.AtomicLong |
messagesInChannels |
|
private OperatorStateMonitor |
monitor |
|
private DataflowProcessor |
processor |
|
private boolean |
shutdownFlag |
Constructor and description |
---|
GracefulShutdownListener
(OperatorStateMonitor monitor) Hooks hooks the shared monitor |
Type | Name and description |
---|---|
void |
afterRun(DataflowProcessor processor, java.util.List<java.lang.Object> messages) Enters an idle state, so a notification needs to be sent to the monitor. |
java.util.List<java.lang.Object> |
beforeRun(DataflowProcessor processor, java.util.List<java.lang.Object> messages) Entering a different non-idle state, so a notification needs to be sent to the monitor. |
java.lang.Object |
controlMessageArrived(DataflowProcessor processor, DataflowReadChannel<java.lang.Object> channel, int index, java.lang.Object message) Entering a non-idle state, so a notification needs to be sent to the monitor. |
private void |
fireEvent() If shutdown is in progress, we'll notify the monitor |
void |
initiateShutdown() Starts the shutdown phase by turning shutdownFlag on |
boolean |
isIdle() A quick check on, whether the operator/selector is in the Idle state |
boolean |
isIdleAndNoIncomingMessages() A more sophisticated test for being Idle |
java.lang.Object |
messageArrived(DataflowProcessor processor, DataflowReadChannel<java.lang.Object> channel, int index, java.lang.Object message) Entering a non-idle state, so a notification needs to be sent to the monitor. |
void |
registered(DataflowProcessor processor) When hooked into an operator/selectors, the listener will tap to its input channels to get notified about all incoming messages. |
void |
terminateProcessor() Used by the monitor to terminate the underlying operator/selector |
Methods inherited from class | Name |
---|---|
class DataflowEventAdapter |
afterRun, afterStart, afterStop, beforeRun, controlMessageArrived, customEvent, messageArrived, messageSentOut, onException, registered |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Hooks hooks the shared monitor
monitor
- The monitor that will orchestrate the shutdownEnters an idle state, so a notification needs to be sent to the monitor.
processor
- The reporting dataflow operator/selectormessages
- The incoming messages that have been processedEntering a different non-idle state, so a notification needs to be sent to the monitor.
processor
- The reporting dataflow operator/selectormessages
- The incoming messagesEntering a non-idle state, so a notification needs to be sent to the monitor. Also, the received message must be removed from the temporary message cache (or added to it so that so that the not-yet-arrived notification from the channel can remove it).
processor
- The reporting dataflow operator/selectorchannel
- The input channel holding the messageindex
- The index of the input channel within the operatormessage
- The incoming messageIf shutdown is in progress, we'll notify the monitor
Starts the shutdown phase by turning shutdownFlag on
A quick check on, whether the operator/selector is in the Idle state
A more sophisticated test for being Idle
Entering a non-idle state, so a notification needs to be sent to the monitor. Also, the received message must be removed from the temporary message cache (or added to it so that so that the not-yet-arrived notification from the channel can remove it).
processor
- The reporting dataflow operator/selectorchannel
- The input channel holding the messageindex
- The index of the input channel within the operatormessage
- The incoming messageWhen hooked into an operator/selectors, the listener will tap to its input channels to get notified about all incoming messages. These incoming messages will be stored temporarily so as the listener can keep track of it until the message is passed to the operator/selector. The messageArrived() event handler will then remove the message from the temporary storage. However, it is not guaranteed that the channel reports an incoming message before the corresponding messageArrived() handler gets invoked. These cases are fine with respect to shutdown, however, we still need to take care of such situation in order to remove the message from teh temporary cache.
processor
- The reporting dataflow operator/selectorUsed by the monitor to terminate the underlying operator/selector
Copyright © 2008–2013 Václav Pech. All Rights Reserved.