@Internal public abstract class AbstractAsyncStateStreamOperatorV2<OUT> extends AbstractStreamOperatorV2<OUT> implements AsyncStateProcessingOperator
AbstractStreamOperatorV2
the ability to
perform AsyncStateProcessing
. The aim is to make any subclass of AbstractStreamOperatorV2
could manipulate async state with only a change of base class.config, lastRecordAttributes, latencyStats, LOG, metrics, output, processingTimeService, timeServiceManager
Constructor and Description |
---|
AbstractAsyncStateStreamOperatorV2(StreamOperatorParameters<OUT> parameters,
int numberOfInputs) |
Modifier and Type | Method and Description |
---|---|
ElementOrder |
getElementOrder()
Get the
ElementOrder of this operator. |
<K,N> InternalTimerService<N> |
getInternalTimerService(String name,
TypeSerializer<N> namespaceSerializer,
Triggerable<K,N> triggerable)
Returns a
InternalTimerService that can be used to query current processing time and
event time and to set timers. |
<T> ThrowingConsumer<StreamRecord<T>,Exception> |
getRecordProcessor(int inputId)
Get the record processor that could process record from input, which is the only entry for
async processing.
|
void |
initializeState(StreamTaskStateInitializer streamTaskStateManager)
Initialize necessary state components for
AbstractStreamOperatorV2 . |
boolean |
isAsyncStateProcessingEnabled()
Get if the async state processing is enabled for this input/operator.
|
void |
postProcessElement()
A callback that will be triggered after an element finishes
processElement . |
void |
preserveRecordOrderAndProcess(ThrowingRunnable<Exception> processing)
Check the order of same-key record, and then process the record.
|
<T> void |
setAsyncKeyedContextElement(StreamRecord<T> record,
KeySelector<T,?> keySelector)
Set key context for async state processing.
|
OperatorSnapshotFutures |
snapshotState(long checkpointId,
long timestamp,
CheckpointOptions checkpointOptions,
CheckpointStreamFactory factory)
Called to draw a state snapshot from the operator.
|
close, finish, getCurrentKey, getExecutionConfig, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getTimeServiceManager, getUserCodeClassloader, initializeState, internalSetKeyContextElement, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, open, prepareSnapshotPreBarrier, processRecordAttributes, processWatermark, processWatermarkStatus, reportOrForwardLatencyMarker, reportWatermark, setCurrentKey, setKeyContextElement1, setKeyContextElement2, snapshotState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeRecordProcessor
getOperatorAttributes
public AbstractAsyncStateStreamOperatorV2(StreamOperatorParameters<OUT> parameters, int numberOfInputs)
public final void initializeState(StreamTaskStateInitializer streamTaskStateManager) throws Exception
AbstractStreamOperatorV2
.initializeState
in interface StreamOperator<OUT>
initializeState
in class AbstractStreamOperatorV2<OUT>
Exception
public boolean isAsyncStateProcessingEnabled()
AsyncStateProcessing
isAsyncStateProcessingEnabled
in interface AsyncStateProcessing
public ElementOrder getElementOrder()
AsyncStateProcessingOperator
ElementOrder
of this operator.getElementOrder
in interface AsyncStateProcessingOperator
public final <T> void setAsyncKeyedContextElement(StreamRecord<T> record, KeySelector<T,?> keySelector) throws Exception
AsyncStateProcessingOperator
setAsyncKeyedContextElement
in interface AsyncStateProcessingOperator
T
- the type of the record.record
- the record.keySelector
- the key selector to select a key from record.Exception
public final void postProcessElement()
AsyncStateProcessingOperator
processElement
.postProcessElement
in interface AsyncStateProcessingOperator
public final void preserveRecordOrderAndProcess(ThrowingRunnable<Exception> processing)
AsyncStateProcessingOperator
AsyncStateProcessingOperator.getElementOrder()
returns ElementOrder.RECORD_ORDER
.preserveRecordOrderAndProcess
in interface AsyncStateProcessingOperator
processing
- the record processing logic.public final <T> ThrowingConsumer<StreamRecord<T>,Exception> getRecordProcessor(int inputId)
AsyncStateProcessing
getRecordProcessor
in interface AsyncStateProcessing
inputId
- the input identifier, start from 1. Borrow the design from org.apache.flink.streaming.api.operators.AbstractInput#inputId
. This is only relevant if
there is multiple inputs for the instance.public final OperatorSnapshotFutures snapshotState(long checkpointId, long timestamp, CheckpointOptions checkpointOptions, CheckpointStreamFactory factory) throws Exception
StreamOperator
snapshotState
in interface StreamOperator<OUT>
snapshotState
in class AbstractStreamOperatorV2<OUT>
Exception
- exception that happened during snapshotting.public <K,N> InternalTimerService<N> getInternalTimerService(String name, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable)
AbstractStreamOperatorV2
InternalTimerService
that can be used to query current processing time and
event time and to set timers. An operator can have several timer services, where each has its
own namespace serializer. Timer services are differentiated by the string key that is given
when requesting them, if you call this method with the same key multiple times you will get
the same timer service instance in subsequent requests.
Timers are always scoped to a key, the currently active key of a keyed stream operation. When a timer fires, this key will also be set as the currently active key.
Each timer has attached metadata, the namespace. Different timer services can have a
different namespace type. If you don't need namespace differentiation you can use VoidNamespaceSerializer
as the namespace serializer.
getInternalTimerService
in class AbstractStreamOperatorV2<OUT>
N
- The type of the timer namespace.name
- The name of the requested timer service. If no service exists under the given
name a new one will be created and returned.namespaceSerializer
- TypeSerializer
for the timer namespace.triggerable
- The Triggerable
that should be invoked when timers fireCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.