|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.operator.DataflowEventAdapter groovyx.gpars.dataflow.operator.component.GracefulShutdownListener
public class GracefulShutdownListener extends DataflowEventAdapter
Listens to an operator/selector and reports its state and activity to a GracefulShutdownMonitor, shared with other listeners.
Field Summary | |
---|---|
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 Summary | |
GracefulShutdownListener(OperatorStateMonitor monitor)
Hooks hooks the shared monitor |
Method Summary | |
---|---|
void
|
afterRun(DataflowProcessor processor, java.util.List messages)
Enters an idle state, so a notification needs to be sent to the monitor. |
java.util.List
|
beforeRun(DataflowProcessor processor, java.util.List messages)
Entering a different non-idle state, so a notification needs to be sent to the monitor. |
java.lang.Object
|
controlMessageArrived(DataflowProcessor processor, DataflowReadChannel 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 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 DataflowEventAdapter | |
---|---|
afterRun, afterStart, afterStop, beforeRun, controlMessageArrived, customEvent, messageArrived, messageSentOut, onException, registered |
Field Detail |
---|
private final java.util.concurrent.atomic.AtomicInteger activeForks
private boolean collectingMessages
private final java.util.concurrent.atomic.AtomicLong messagesInChannels
private final OperatorStateMonitor monitor
private DataflowProcessor processor
private boolean shutdownFlag
Constructor Detail |
---|
public GracefulShutdownListener(OperatorStateMonitor monitor)
monitor
- The monitor that will orchestrate the shutdown
Method Detail |
---|
@Override public void afterRun(DataflowProcessor processor, java.util.List messages)
processor
- The reporting dataflow operator/selectormessages
- The incoming messages that have been processed
@Override public java.util.List beforeRun(DataflowProcessor processor, java.util.List messages)
processor
- The reporting dataflow operator/selectormessages
- The incoming messages
@Override public java.lang.Object controlMessageArrived(DataflowProcessor processor, DataflowReadChannel channel, int index, java.lang.Object message)
processor
- The reporting dataflow operator/selectorchannel
- The input channel holding the messageindex
- The index of the input channel within the operatormessage
- The incoming message
private void fireEvent()
final void initiateShutdown()
public final boolean isIdle()
public final boolean isIdleAndNoIncomingMessages()
@Override public java.lang.Object messageArrived(DataflowProcessor processor, DataflowReadChannel channel, int index, java.lang.Object message)
processor
- The reporting dataflow operator/selectorchannel
- The input channel holding the messageindex
- The index of the input channel within the operatormessage
- The incoming message
@Override public void registered(DataflowProcessor processor)
processor
- The reporting dataflow operator/selector
final void terminateProcessor()
Copyright © 2008–2012 Václav Pech. All Rights Reserved.