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 a
timer 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceWatermark(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>getInternalTimerService(String name, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, Triggerable<K, N> triggerable) Creates anInternalTimerServicefor handling a group of timers identified by the givenname.intintvoidsnapshotToRawKeyedState(KeyedStateCheckpointOutputStream out, String operatorName) Snapshots the timers to raw keyed state.booleantryAdvanceWatermark(Watermark watermark, InternalTimeServiceManager.ShouldStopAdvancingFn shouldStopAdvancingFn) Try toInternalTimeServiceManager.advanceWatermark(Watermark), but ifInternalTimeServiceManager.ShouldStopAdvancingFnreturnstrue, stop the advancement and return as soon as possible.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Method Details
-
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, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, Triggerable<K, N> triggerable) Description copied from interface:InternalTimeServiceManagerCreates anInternalTimerServicefor handling a group of timers identified by the givenname. The timers are scoped to a key and namespace.When a timer fires the given
Triggerablewill be invoked.- Specified by:
getInternalTimerServicein interfaceInternalTimeServiceManager<K>
-
advanceWatermark
Description copied from interface:InternalTimeServiceManagerAdvances the Watermark of all managedtimer services, potentially firing event time timers.- Specified by:
advanceWatermarkin interfaceInternalTimeServiceManager<K>- Throws:
Exception
-
tryAdvanceWatermark
public boolean tryAdvanceWatermark(Watermark watermark, InternalTimeServiceManager.ShouldStopAdvancingFn shouldStopAdvancingFn) throws Exception Description copied from interface:InternalTimeServiceManagerTry toInternalTimeServiceManager.advanceWatermark(Watermark), but ifInternalTimeServiceManager.ShouldStopAdvancingFnreturnstrue, stop the advancement and return as soon as possible.- Specified by:
tryAdvanceWatermarkin interfaceInternalTimeServiceManager<K>- Returns:
- true if
Watermarkhas been fully processed, false otherwise. - Throws:
Exception
-
snapshotToRawKeyedState
public void snapshotToRawKeyedState(KeyedStateCheckpointOutputStream out, String operatorName) throws Exception Description copied from interface:InternalTimeServiceManagerSnapshots the timers to raw keyed state.TODO: This can be removed once heap-based timers are integrated with RocksDB incremental snapshots.
- Specified by:
snapshotToRawKeyedStatein interfaceInternalTimeServiceManager<K>- Throws:
Exception
-
numProcessingTimeTimers
@VisibleForTesting public int numProcessingTimeTimers() -
numEventTimeTimers
@VisibleForTesting public int numEventTimeTimers()
-