OUT
- The output type of the operator@PublicEvolving public abstract class AbstractStreamOperator<OUT> extends Object implements StreamOperator<OUT>, Serializable
AbstractUdfStreamOperator
instead (which is a specialized subclass of this class).
For concrete implementations, one of the following two interfaces must also be implemented, to
mark the operator as unary or binary:
OneInputStreamOperator
or
TwoInputStreamOperator
.
Methods of StreamOperator
are guaranteed not to be called concurrently. Also, if using
the timer service, timer callbacks are also guaranteed not to be called concurrently with
methods on StreamOperator
.
Modifier and Type | Field and Description |
---|---|
protected ChainingStrategy |
chainingStrategy |
protected static org.slf4j.Logger |
LOG
The logger used by the operator class and its subclasses
|
protected Output<StreamRecord<OUT>> |
output |
Constructor and Description |
---|
AbstractStreamOperator() |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method is called after all records have been added to the operators via the methods
OneInputStreamOperator.processElement(StreamRecord) , or
TwoInputStreamOperator.processElement1(StreamRecord) and
TwoInputStreamOperator.processElement2(StreamRecord) . |
void |
disableInputCopy()
Enable object-reuse for this operator instance.
|
void |
dispose()
This method is called at the very end of the operator's life, both in the case of a successful
completion of the operation, and in the case of a failure and canceling.
|
ChainingStrategy |
getChainingStrategy() |
StreamTask<?,?> |
getContainingTask() |
ExecutionConfig |
getExecutionConfig()
Gets the execution config defined on the execution environment of the job to which this
operator belongs.
|
StreamConfig |
getOperatorConfig() |
protected <S extends State,N> |
getPartitionedState(N namespace,
TypeSerializer<N> namespaceSerializer,
StateDescriptor<S,?> stateDescriptor)
Creates a partitioned state handle, using the state backend configured for this task.
|
protected <S extends State> |
getPartitionedState(StateDescriptor<S,?> stateDescriptor)
Creates a partitioned state handle, using the state backend configured for this task.
|
StreamingRuntimeContext |
getRuntimeContext()
Returns a context that allows the operator to query information about the execution and also
to interact with systems such as broadcast variables and managed state.
|
AbstractStateBackend |
getStateBackend() |
ClassLoader |
getUserCodeClassloader() |
boolean |
isInputCopyingDisabled()
An operator can return true here to disable copying of its input elements.
|
void |
notifyOfCompletedCheckpoint(long checkpointId)
Called when the checkpoint with the given ID is completed and acknowledged on the JobManager.
|
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic.
|
protected void |
registerTimer(long time,
Triggerable target)
Register a timer callback.
|
void |
restoreState(StreamTaskState state,
long recoveryTimestamp)
Restores the operator state, if this operator's execution is recovering from a checkpoint.
|
void |
setChainingStrategy(ChainingStrategy strategy) |
void |
setKeyContext(Object key) |
void |
setKeyContextElement1(StreamRecord record) |
void |
setKeyContextElement2(StreamRecord record) |
void |
setup(StreamTask<?,?> containingTask,
StreamConfig config,
Output<StreamRecord<OUT>> output)
Initializes the operator.
|
StreamTaskState |
snapshotOperatorState(long checkpointId,
long timestamp)
Called to draw a state snapshot from the operator.
|
protected static final org.slf4j.Logger LOG
protected ChainingStrategy chainingStrategy
protected transient Output<StreamRecord<OUT>> output
public void setup(StreamTask<?,?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output)
StreamOperator
setup
in interface StreamOperator<OUT>
public void open() throws Exception
The default implementation does nothing.
open
in interface StreamOperator<OUT>
Exception
- An exception in this method causes the operator to fail.public void close() throws Exception
OneInputStreamOperator.processElement(StreamRecord)
, or
TwoInputStreamOperator.processElement1(StreamRecord)
and
TwoInputStreamOperator.processElement2(StreamRecord)
.
The method is expected to flush all remaining buffered data. Exceptions during this flushing of buffered should be propagated, in order to cause the operation to be recognized asa failed, because the last data items are not processed properly.
close
in interface StreamOperator<OUT>
Exception
- An exception in this method causes the operator to fail.public void dispose()
dispose
in interface StreamOperator<OUT>
public StreamTaskState snapshotOperatorState(long checkpointId, long timestamp) throws Exception
StreamOperator
snapshotOperatorState
in interface StreamOperator<OUT>
checkpointId
- The ID of the checkpoint.timestamp
- The timestamp of the checkpoint.Exception
- Forwards exceptions that occur while drawing snapshots from the operator
and the key/value state.public void restoreState(StreamTaskState state, long recoveryTimestamp) throws Exception
StreamOperator
This method is called after StreamOperator.setup(StreamTask, StreamConfig, Output)
and before StreamOperator.open()
.
restoreState
in interface StreamOperator<OUT>
state
- The state of operator that was snapshotted as part of checkpoint
from which the execution is restored.recoveryTimestamp
- Global recovery timestampException
- Exceptions during state restore should be forwarded, so that the system can
properly react to failed state restore and fail the execution attempt.public void notifyOfCompletedCheckpoint(long checkpointId) throws Exception
StreamOperator
notifyOfCompletedCheckpoint
in interface StreamOperator<OUT>
checkpointId
- The ID of the checkpoint that has been completed.Exception
- Exceptions during checkpoint acknowledgement may be forwarded and will cause
the program to fail and enter recovery.public ExecutionConfig getExecutionConfig()
public StreamConfig getOperatorConfig()
public StreamTask<?,?> getContainingTask()
public ClassLoader getUserCodeClassloader()
public StreamingRuntimeContext getRuntimeContext()
public AbstractStateBackend getStateBackend()
protected void registerTimer(long time, Triggerable target)
Triggerable
will be invoked.
This call is guaranteed to not happen concurrently with method calls on the operator.time
- The absolute time in milliseconds.target
- The target to be triggered.protected <S extends State> S getPartitionedState(StateDescriptor<S,?> stateDescriptor) throws Exception
IllegalStateException
- Thrown, if the key/value state was already initialized.Exception
- Thrown, if the state backend cannot create the key/value state.protected <S extends State,N> S getPartitionedState(N namespace, TypeSerializer<N> namespaceSerializer, StateDescriptor<S,?> stateDescriptor) throws Exception
IllegalStateException
- Thrown, if the key/value state was already initialized.Exception
- Thrown, if the state backend cannot create the key/value state.public void setKeyContextElement1(StreamRecord record) throws Exception
setKeyContextElement1
in interface StreamOperator<OUT>
Exception
public void setKeyContextElement2(StreamRecord record) throws Exception
setKeyContextElement2
in interface StreamOperator<OUT>
Exception
public void setKeyContext(Object key)
public final void setChainingStrategy(ChainingStrategy strategy)
setChainingStrategy
in interface StreamOperator<OUT>
public final ChainingStrategy getChainingStrategy()
getChainingStrategy
in interface StreamOperator<OUT>
public boolean isInputCopyingDisabled()
StreamOperator
ExecutionConfig
isInputCopyingDisabled
in interface StreamOperator<OUT>
public void disableInputCopy()
ExecutionConfig
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.