@Internal public abstract class AbstractAsyncStateStreamOperator<OUT> extends AbstractStreamOperator<OUT> implements AsyncStateProcessingOperator
AbstractStreamOperator
the ability to
perform AsyncStateProcessing
. The aim is to make any subclass of AbstractStreamOperator
could manipulate async state with only a change of base class.chainingStrategy, config, lastRecordAttributes1, lastRecordAttributes2, latencyStats, LOG, metrics, output, processingTimeService, stateHandler, stateKeySelector1, stateKeySelector2, timeServiceManager
Constructor and Description |
---|
AbstractAsyncStateStreamOperator() |
Modifier and Type | Method and Description |
---|---|
Object |
getCurrentKey() |
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
AbstractStreamOperator . |
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.
|
void |
processWatermark(Watermark mark) |
void |
processWatermarkStatus(WatermarkStatus watermarkStatus) |
<T> void |
setAsyncKeyedContextElement(StreamRecord<T> record,
KeySelector<T,?> keySelector)
Set key context for async state processing.
|
void |
setKeyContextElement1(StreamRecord record) |
void |
setKeyContextElement2(StreamRecord record) |
OperatorSnapshotFutures |
snapshotState(long checkpointId,
long timestamp,
CheckpointOptions checkpointOptions,
CheckpointStreamFactory factory)
Called to draw a state snapshot from the operator.
|
close, finish, getChainingStrategy, getContainingTask, getExecutionConfig, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getStateKeySelector1, getStateKeySelector2, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, open, prepareSnapshotPreBarrier, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark1, processWatermark2, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setMailboxExecutor, setProcessingTimeService, setup, snapshotState, useSplittableTimers
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeRecordProcessor
getOperatorAttributes
hasKeyContext
public void initializeState(StreamTaskStateInitializer streamTaskStateManager) throws Exception
AbstractStreamOperator
.initializeState
in interface StreamOperator<OUT>
initializeState
in class AbstractStreamOperator<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 AbstractStreamOperator<OUT>
Exception
- exception that happened during snapshotting.public <K,N> InternalTimerService<N> getInternalTimerService(String name, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable)
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 AbstractStreamOperator<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 firepublic void setKeyContextElement1(StreamRecord record) throws Exception
setKeyContextElement1
in interface StreamOperator<OUT>
setKeyContextElement1
in class AbstractStreamOperator<OUT>
Exception
public void setKeyContextElement2(StreamRecord record) throws Exception
setKeyContextElement2
in interface StreamOperator<OUT>
setKeyContextElement2
in class AbstractStreamOperator<OUT>
Exception
public Object getCurrentKey()
getCurrentKey
in interface KeyContext
getCurrentKey
in class AbstractStreamOperator<OUT>
public void processWatermark(Watermark mark) throws Exception
processWatermark
in class AbstractStreamOperator<OUT>
Exception
public void processWatermarkStatus(WatermarkStatus watermarkStatus) throws Exception
processWatermarkStatus
in class AbstractStreamOperator<OUT>
Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.