Class InternalTimeServiceManagerImpl<K>
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.InternalTimeServiceManagerImpl<K>
-
- Type Parameters:
K
- The type of keys used for the timers and the registry.
- All Implemented Interfaces:
InternalTimeServiceManager<K>
@Internal public class InternalTimeServiceManagerImpl<K> extends Object implements InternalTimeServiceManager<K>
An entity keeping all the time-related services. Right now, this is only atimer services
.NOTE: These services are only available to keyed operators.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.streaming.api.operators.InternalTimeServiceManager
InternalTimeServiceManager.Provider, InternalTimeServiceManager.ShouldStopAdvancingFn
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
LOG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceWatermark(Watermark watermark)
Advances the Watermark of all managedtimer services
, potentially firing event time timers.static <K> InternalTimeServiceManagerImpl<K>
create(TaskIOMetricGroup taskIOMetricGroup, PriorityQueueSetFactory factory, KeyGroupRange keyGroupRange, ClassLoader userClassloader, KeyContext keyContext, ProcessingTimeService processingTimeService, Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates, StreamTaskCancellationContext cancellationContext)
A factory method for creating theInternalTimeServiceManagerImpl
.<N> InternalTimerService<N>
getAsyncInternalTimerService(String name, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable, AsyncExecutionController<K> asyncExecutionController)
Creates anInternalTimerServiceAsyncImpl
for handling a group of timers identified by the givenname
.<N> InternalTimerService<N>
getInternalTimerService(String name, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable)
Creates anInternalTimerService
for handling a group of timers identified by the givenname
.int
numEventTimeTimers()
int
numProcessingTimeTimers()
void
snapshotToRawKeyedState(KeyedStateCheckpointOutputStream out, String operatorName)
Snapshots the timers to raw keyed state.boolean
tryAdvanceWatermark(Watermark watermark, InternalTimeServiceManager.ShouldStopAdvancingFn shouldStopAdvancingFn)
Try toInternalTimeServiceManager.advanceWatermark(Watermark)
, but ifInternalTimeServiceManager.ShouldStopAdvancingFn
returnstrue
, stop the advancement and return as soon as possible.
-
-
-
Method Detail
-
create
public static <K> InternalTimeServiceManagerImpl<K> create(TaskIOMetricGroup taskIOMetricGroup, PriorityQueueSetFactory factory, KeyGroupRange keyGroupRange, ClassLoader userClassloader, KeyContext keyContext, ProcessingTimeService processingTimeService, Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates, StreamTaskCancellationContext cancellationContext) throws Exception
A factory method for creating theInternalTimeServiceManagerImpl
.IMPORTANT: Keep in sync with
InternalTimeServiceManager.Provider
.- Throws:
Exception
-
getInternalTimerService
public <N> InternalTimerService<N> getInternalTimerService(String name, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable)
Description copied from interface:InternalTimeServiceManager
Creates anInternalTimerService
for handling a group of timers identified by the givenname
. The timers are scoped to a key and namespace.When a timer fires the given
Triggerable
will be invoked.- Specified by:
getInternalTimerService
in interfaceInternalTimeServiceManager<K>
-
getAsyncInternalTimerService
public <N> InternalTimerService<N> getAsyncInternalTimerService(String name, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerable, AsyncExecutionController<K> asyncExecutionController)
Description copied from interface:InternalTimeServiceManager
Creates anInternalTimerServiceAsyncImpl
for handling a group of timers identified by the givenname
. The timers are scoped to a key and namespace. Mainly used by async operators.Some essential order preservation will be added when the given
Triggerable
is invoked.- Specified by:
getAsyncInternalTimerService
in interfaceInternalTimeServiceManager<K>
-
advanceWatermark
public void advanceWatermark(Watermark watermark) throws Exception
Description copied from interface:InternalTimeServiceManager
Advances the Watermark of all managedtimer services
, potentially firing event time timers.- Specified by:
advanceWatermark
in interfaceInternalTimeServiceManager<K>
- Throws:
Exception
-
tryAdvanceWatermark
public boolean tryAdvanceWatermark(Watermark watermark, InternalTimeServiceManager.ShouldStopAdvancingFn shouldStopAdvancingFn) throws Exception
Description copied from interface:InternalTimeServiceManager
Try toInternalTimeServiceManager.advanceWatermark(Watermark)
, but ifInternalTimeServiceManager.ShouldStopAdvancingFn
returnstrue
, stop the advancement and return as soon as possible.- Specified by:
tryAdvanceWatermark
in interfaceInternalTimeServiceManager<K>
- Returns:
- true if
Watermark
has been fully processed, false otherwise. - Throws:
Exception
-
snapshotToRawKeyedState
public void snapshotToRawKeyedState(KeyedStateCheckpointOutputStream out, String operatorName) throws Exception
Description copied from interface:InternalTimeServiceManager
Snapshots the timers to raw keyed state.TODO: This can be removed once heap-based timers are integrated with RocksDB incremental snapshots.
- Specified by:
snapshotToRawKeyedState
in interfaceInternalTimeServiceManager<K>
- Throws:
Exception
-
numProcessingTimeTimers
@VisibleForTesting public int numProcessingTimeTimers()
-
numEventTimeTimers
@VisibleForTesting public int numEventTimeTimers()
-
-