public abstract class AbstractStage extends Object
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger
This stage's unique logger
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractStage() |
protected |
AbstractStage(org.slf4j.Logger logger) |
Modifier and Type | Method and Description |
---|---|
protected void |
abort() |
protected void |
addInputPortRemovedListener(PortRemovedListener<InputPort<?>> inputPortRemovedListener) |
protected void |
addOutputPortRemovedListener(PortRemovedListener<OutputPort<?>> outputPortRemovedListener) |
boolean |
compareAndSetBeingExecuted(boolean newValue) |
protected <T> InputPort<T> |
createInputPort()
Creates and adds an InputPort to the stage
|
protected <T> InputPort<T> |
createInputPort(Class<T> type)
Creates and adds an InputPort to the stage
|
protected <T> InputPort<T> |
createInputPort(Class<T> type,
String name)
Creates and adds an InputPort to the stage
|
protected <T> InputPort<T> |
createInputPort(String name)
Creates and adds an InputPort to the stage
|
protected <T> OutputPort<T> |
createOutputPort()
Creates and adds an OutputPort to the stage
|
protected <T> OutputPort<T> |
createOutputPort(Class<T> type)
Creates and adds an OutputPort to the stage
|
protected <T> OutputPort<T> |
createOutputPort(Class<T> type,
String name)
Creates and adds an OutputPort to the stage
|
protected <T> OutputPort<T> |
createOutputPort(String name)
Creates and adds an OutputPort to the stage
|
void |
declareActive()
Declares this stage to be executed by an own thread.
|
void |
declarePassive()
Declares this stage to be executed by the thread of its predecessor stage.
|
protected abstract void |
execute()
Contains the logic of this stage and is invoked (possibly multiple times) by the framework.
|
void |
executeByFramework()
This method is internally called by the framework.
|
StageState |
getCurrentState()
This method is thread-safe.
|
String |
getId() |
protected List<InputPort<?>> |
getInputPorts() |
protected List<OutputPort<?>> |
getOutputPorts() |
protected Thread |
getOwningThread() |
protected TerminationStrategy |
getTerminationStrategy()
Deprecated.
since 3.0.
We will completely remove framework-backed support for infinite producers since it has never worked correctly in all (corner) cases.
Instead, please use finite producers and implement an appropriate termination condition by your own.
|
boolean |
isActive() |
boolean |
isBeingExecuted() |
boolean |
isPaused() |
boolean |
isProducer() |
boolean |
isStateless()
This method is used by some schedulers to improve parallelism and thus to improve the overall performance.
|
void |
onSignal(ISignal signal,
InputPort<?> inputPort)
May not be invoked outside of IPipe implementations
|
protected void |
onStarting()
Event that is triggered, if all of the following conditions hold:
after passing the validation phase and
after the threads are ready-to-run and
just before the threads execute any stage.
|
protected 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 |
onValidating(List<InvalidPortConnection> invalidPortConnections)
Event that is triggered, if all of the following conditions hold:
after constructing this stage and
before starting the analysis.
|
protected void |
removeDynamicPort(InputPort<?> inputPort) |
protected void |
removeDynamicPort(OutputPort<?> outputPort) |
void |
setPaused(boolean newValue) |
protected void |
setStateless(boolean stateless) |
protected boolean |
shouldBeTerminated() |
protected boolean |
signalAlreadyReceived(ISignal signal,
InputPort<?> inputPort) |
protected void |
terminateStage()
Deprecated.
since 3.0. Use
workCompleted() instead. |
String |
toString()
Returns a string representation of this stage including its unique identifier.
|
protected void |
workCompleted()
Marks this stage as having finished its work such that it will not be scheduled anymore.
|
protected AbstractStage()
protected AbstractStage(org.slf4j.Logger logger)
logger
- a custom logger (potentially shared by multiple stage instances)public boolean isBeingExecuted()
public boolean compareAndSetBeingExecuted(boolean newValue)
public void setPaused(boolean newValue)
public boolean isPaused()
public String getId()
public String toString()
public final void executeByFramework() throws TerminateException
TerminateException
protected abstract void execute() throws Exception
Exception
- arbitrary exception triggered by the logic of this stageprotected Thread getOwningThread()
public boolean isActive()
public void declareActive()
public void declarePassive()
protected List<OutputPort<?>> getOutputPorts()
public StageState getCurrentState()
StageState
)public void onSignal(ISignal signal, InputPort<?> inputPort)
signal
- The incoming signalinputPort
- The port which received the signalprotected boolean signalAlreadyReceived(ISignal signal, InputPort<?> inputPort)
signal
- arriving signalinputPort
- which received the signaltrue
if this stage has already received the given signal
, false
otherwisepublic void onValidating(List<InvalidPortConnection> invalidPortConnections)
If stage developers want to override this method, they must always call the super implementation first:
@Override public void onValidating() { super.onValidating(); // insert your code here }
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.
invalidPortConnections
- protected void onStarting()
If stage developers want to override this method, they must always call the super implementation first:
@Override protected void onStarting() { super.onStarting(); // insert your code here }
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.
protected void onTerminating()
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.
protected <T> InputPort<T> createInputPort()
T
- the type of elements to be receivedprotected <T> InputPort<T> createInputPort(Class<T> type)
T
- the type of elements to be receivedtype
- class of elements to be receivedprotected <T> InputPort<T> createInputPort(String name)
T
- the type of elements to be receivedname
- a specific name for the new portprotected <T> InputPort<T> createInputPort(Class<T> type, String name)
T
- the type of elements to be receivedtype
- class of elements to be receivedname
- a specific name for the new portprotected <T> OutputPort<T> createOutputPort()
T
- the type of elements to be sentprotected <T> OutputPort<T> createOutputPort(Class<T> type)
T
- the type of elements to be senttype
- class of elements to be sentprotected <T> OutputPort<T> createOutputPort(String name)
T
- the type of elements to be sentname
- a specific name for the new portprotected <T> OutputPort<T> createOutputPort(Class<T> type, String name)
T
- the type of elements to be sentname
- a specific name for the new porttype
- class of elements to be sent@Deprecated protected void terminateStage()
workCompleted()
instead.protected void workCompleted()
This method may only be invoked by producers.
Otherwise an UnsupportedOperationException
is thrown.
protected void abort()
protected boolean shouldBeTerminated()
@Deprecated protected TerminationStrategy getTerminationStrategy()
protected void removeDynamicPort(OutputPort<?> outputPort)
protected void removeDynamicPort(InputPort<?> inputPort)
protected final void addOutputPortRemovedListener(PortRemovedListener<OutputPort<?>> outputPortRemovedListener)
protected final void addInputPortRemovedListener(PortRemovedListener<InputPort<?>> inputPortRemovedListener)
public boolean isProducer()
true
iff this stage has no input ports, false
otherwise.public boolean isStateless()
true
iff this stage has no internal fields which represent some kind of state; false
otherwise.protected void setStateless(boolean stateless)
Copyright © 2015–2020. All rights reserved.