public class DynamicDistributor<T> extends Distributor<T> implements PortRemovedListener<OutputPort<?>>
Modifier and Type | Field and Description |
---|---|
protected BlockingQueue<PortAction<DynamicDistributor<T>>> |
portActions |
strategy
inputPort
logger
Constructor and Description |
---|
DynamicDistributor()
Uses
NonBlockingRoundRobinStrategy as default distributor strategy. |
DynamicDistributor(IDistributorStrategy strategy) |
Modifier and Type | Method and Description |
---|---|
boolean |
addPortActionRequest(PortAction<DynamicDistributor<T>> newPortActionRequest) |
protected void |
checkForPendingPortActionRequest() |
protected void |
execute(T element)
Contains the logic of this stage and is invoked (possibly multiple times) by the framework.
|
void |
onPortRemoved(OutputPort<?> removedOutputPort) |
void |
onTerminating()
Event that is triggered, if all of the following conditions hold:
while executing the P&F configuration and
after receiving the termination signal.
|
void |
removeDynamicPort(OutputPort<?> outputPort) |
getNewOutputPort, getOutputPorts, getStrategy, setStrategy
createInputPort, execute, getInputPort
abort, addInputPortRemovedListener, addOutputPortRemovedListener, compareAndSetBeingExecuted, createInputPort, createInputPort, createInputPort, createOutputPort, createOutputPort, createOutputPort, createOutputPort, declareActive, declarePassive, executeByFramework, getCurrentState, getId, getInputPorts, getOwningThread, getTerminationStrategy, isActive, isBeingExecuted, isPaused, isProducer, isStateless, onSignal, onStarting, onValidating, removeDynamicPort, setPaused, setStateless, shouldBeTerminated, signalAlreadyReceived, terminateStage, toString, workCompleted
protected final BlockingQueue<PortAction<DynamicDistributor<T>>> portActions
public DynamicDistributor()
NonBlockingRoundRobinStrategy
as default distributor strategy.public DynamicDistributor(IDistributorStrategy strategy)
protected void execute(T element)
AbstractConsumerStage
execute
in class Distributor<T>
element
- the next non-null element from the (only) input port of this stageprotected void checkForPendingPortActionRequest()
public void onTerminating()
AbstractStage
If stage developers want to override this method, they must always call the super implementation last:
@Override protected void onTerminating() { // insert your code here super.onTerminating(); }
To throw a checked exception, wrap it to an unchecked exception, e.g. to an IllegalArgumentException.IllegalArgumentException(String, Throwable)
.
Always pass the original exception to the new unchecked exception to allow easy debugging.
onTerminating
in class AbstractStage
public void removeDynamicPort(OutputPort<?> outputPort)
removeDynamicPort
in class AbstractStage
public boolean addPortActionRequest(PortAction<DynamicDistributor<T>> newPortActionRequest)
public void onPortRemoved(OutputPort<?> removedOutputPort)
onPortRemoved
in interface PortRemovedListener<OutputPort<?>>
Copyright © 2015–2020. All rights reserved.