@Internal public final class StateBootstrapWrapperOperator<IN,OUT,OP extends AbstractStreamOperator<OUT> & OneInputStreamOperator<IN,OUT>> extends Object implements OneInputStreamOperator<IN,TaggedOperatorSubtaskState>, SetupableStreamOperator<TaggedOperatorSubtaskState>, BoundedOneInput
Constructor and Description |
---|
StateBootstrapWrapperOperator(long timestamp,
Path savepointPath,
OP operator) |
Modifier and Type | Method and Description |
---|---|
void |
close()
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.
|
void |
endInput()
It is notified that no more data will arrive from the input.
|
void |
finish()
This method is called at the end of data processing.
|
ChainingStrategy |
getChainingStrategy() |
Object |
getCurrentKey() |
OperatorMetricGroup |
getMetricGroup() |
OperatorID |
getOperatorID() |
void |
initializeState(StreamTaskStateInitializer streamTaskStateManager)
Provides a context to initialize all state in the operator.
|
void |
notifyCheckpointComplete(long checkpointId)
Notifies the listener that the checkpoint with the given
checkpointId completed and
was committed. |
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic.
|
void |
prepareSnapshotPreBarrier(long checkpointId)
This method is called when the operator should do a snapshot, before it emits its own
checkpoint barrier.
|
void |
processElement(StreamRecord<IN> element)
Processes one element that arrived on this input of the
MultipleInputStreamOperator . |
void |
processLatencyMarker(LatencyMarker latencyMarker)
Processes a
LatencyMarker that arrived on the first input of this two-input operator. |
void |
processWatermark(Watermark mark)
Processes a
Watermark that arrived on the first input of this two-input operator. |
void |
processWatermarkStatus(WatermarkStatus watermarkStatus)
Processes a
WatermarkStatus that arrived on this input of the MultipleInputStreamOperator . |
void |
setChainingStrategy(ChainingStrategy strategy) |
void |
setCurrentKey(Object key) |
void |
setKeyContextElement1(StreamRecord<?> record) |
void |
setKeyContextElement2(StreamRecord<?> record) |
void |
setup(StreamTask<?,?> containingTask,
StreamConfig config,
Output<StreamRecord<TaggedOperatorSubtaskState>> output)
Initializes the operator.
|
OperatorSnapshotFutures |
snapshotState(long checkpointId,
long timestamp,
CheckpointOptions checkpointOptions,
CheckpointStreamFactory storageLocation)
Called to draw a state snapshot from the operator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setKeyContextElement
getOperatorAttributes
notifyCheckpointAborted
processRecordAttributes
public void setup(StreamTask<?,?> containingTask, StreamConfig config, Output<StreamRecord<TaggedOperatorSubtaskState>> output)
SetupableStreamOperator
setup
in interface SetupableStreamOperator<TaggedOperatorSubtaskState>
public void processElement(StreamRecord<IN> element) throws Exception
Input
MultipleInputStreamOperator
.
This method is guaranteed to not be called concurrently with other methods of the operator.processElement
in interface Input<IN>
Exception
public void processWatermark(Watermark mark) throws Exception
Input
Watermark
that arrived on the first input of this two-input operator.
This method is guaranteed to not be called concurrently with other methods of the operator.processWatermark
in interface Input<IN>
Exception
Watermark
public void processLatencyMarker(LatencyMarker latencyMarker) throws Exception
Input
LatencyMarker
that arrived on the first input of this two-input operator.
This method is guaranteed to not be called concurrently with other methods of the operator.processLatencyMarker
in interface Input<IN>
Exception
LatencyMarker
public void processWatermarkStatus(WatermarkStatus watermarkStatus) throws Exception
Input
WatermarkStatus
that arrived on this input of the MultipleInputStreamOperator
. This method is guaranteed to not be called concurrently with
other methods of the operator.processWatermarkStatus
in interface Input<IN>
Exception
WatermarkStatus
public void open() throws Exception
StreamOperator
open
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
- An exception in this method causes the operator to fail.public void finish() throws Exception
StreamOperator
The method is expected to flush all remaining buffered data. Exceptions during this flushing of buffered data should be propagated, in order to cause the operation to be recognized as failed, because the last data items are not processed properly.
After this method is called, no more records can be produced for the downstream operators.
WARNING: It is not safe to use this method to commit any transactions or other side
effects! You can use this method to flush any buffered data that can later on be committed
e.g. in a CheckpointListener.notifyCheckpointComplete(long)
.
NOTE:This method does not need to close any resources. You should release external
resources in the StreamOperator.close()
method.
finish
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
- An exception in this method causes the operator to fail.public void close() throws Exception
StreamOperator
This method is expected to make a thorough effort to release all resources that the operator has acquired.
NOTE:It can not emit any records! If you need to emit records at the end of
processing, do so in the StreamOperator.finish()
method.
close
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
public void prepareSnapshotPreBarrier(long checkpointId) throws Exception
StreamOperator
This method is intended not for any actual state persistence, but only for emitting some data before emitting the checkpoint barrier. Operators that maintain some small transient state that is inefficient to checkpoint (especially when it would need to be checkpointed in a re-scalable way) but can simply be sent downstream before the checkpoint. An example are opportunistic pre-aggregation operators, which have small the pre-aggregation state that is frequently flushed downstream.
Important: This method should not be used for any actual state snapshot logic, because it will inherently be within the synchronous part of the operator's checkpoint. If heavy work is done within this method, it will affect latency and downstream checkpoint alignments.
prepareSnapshotPreBarrier
in interface StreamOperator<TaggedOperatorSubtaskState>
checkpointId
- The ID of the checkpoint.Exception
- Throwing an exception here causes the operator to fail and go into
recovery.public OperatorSnapshotFutures snapshotState(long checkpointId, long timestamp, CheckpointOptions checkpointOptions, CheckpointStreamFactory storageLocation) throws Exception
StreamOperator
snapshotState
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
- exception that happened during snapshotting.public void initializeState(StreamTaskStateInitializer streamTaskStateManager) throws Exception
StreamOperator
initializeState
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
public void setKeyContextElement1(StreamRecord<?> record) throws Exception
setKeyContextElement1
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
public void setKeyContextElement2(StreamRecord<?> record) throws Exception
setKeyContextElement2
in interface StreamOperator<TaggedOperatorSubtaskState>
Exception
public ChainingStrategy getChainingStrategy()
getChainingStrategy
in interface SetupableStreamOperator<TaggedOperatorSubtaskState>
public void setChainingStrategy(ChainingStrategy strategy)
setChainingStrategy
in interface SetupableStreamOperator<TaggedOperatorSubtaskState>
public OperatorMetricGroup getMetricGroup()
getMetricGroup
in interface StreamOperator<TaggedOperatorSubtaskState>
public OperatorID getOperatorID()
getOperatorID
in interface StreamOperator<TaggedOperatorSubtaskState>
public void notifyCheckpointComplete(long checkpointId) throws Exception
CheckpointListener
checkpointId
completed and
was committed.
These notifications are "best effort", meaning they can sometimes be skipped. To behave
properly, implementers need to follow the "Checkpoint Subsuming Contract". Please see the
class-level JavaDocs
for details.
Please note that checkpoints may generally overlap, so you cannot assume that the notifyCheckpointComplete()
call is always for the latest prior checkpoint (or snapshot) that
was taken on the function/operator implementing this interface. It might be for a checkpoint
that was triggered earlier. Implementing the "Checkpoint Subsuming Contract" (see above)
properly handles this situation correctly as well.
Please note that throwing exceptions from this method will not cause the completed checkpoint to be revoked. Throwing exceptions will typically cause task/job failure and trigger recovery.
notifyCheckpointComplete
in interface CheckpointListener
checkpointId
- The ID of the checkpoint that has been completed.Exception
- This method can propagate exceptions, which leads to a failure/recovery for
the task. Note that this will NOT lead to the checkpoint being revoked.public void setCurrentKey(Object key)
setCurrentKey
in interface KeyContext
public Object getCurrentKey()
getCurrentKey
in interface KeyContext
public void endInput() throws Exception
BoundedOneInput
WARNING: It is not safe to use this method to commit any transactions or other side
effects! You can use this method to flush any buffered data that can later on be committed
e.g. in a CheckpointListener.notifyCheckpointComplete(long)
.
NOTE: Given it is semantically very similar to the StreamOperator.finish()
method. It might be dropped in favour of the other method at some point in time.
endInput
in interface BoundedOneInput
Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.