Class InternalTimerServiceImpl<K,N>
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.InternalTimerServiceImpl<K,N>
-
- All Implemented Interfaces:
InternalTimerService<N>
public class InternalTimerServiceImpl<K,N> extends Object implements InternalTimerService<N>
InternalTimerServicethat stores timers on the Java heap.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceWatermark(long time)longcurrentProcessingTime()Returns the current processing time.longcurrentWatermark()Returns the current event-time watermark.voiddeleteEventTimeTimer(N namespace, long time)Deletes the timer for the given key and namespace.voiddeleteProcessingTimeTimer(N namespace, long time)Deletes the timer for the given key and namespace.voidforEachEventTimeTimer(org.apache.flink.util.function.BiConsumerWithException<N,Long,Exception> consumer)Performs an action for each registered timer.voidforEachProcessingTimeTimer(org.apache.flink.util.function.BiConsumerWithException<N,Long,Exception> consumer)Performs an action for each registered timer.org.apache.flink.api.common.typeutils.TypeSerializer<K>getKeySerializer()org.apache.flink.api.common.typeutils.TypeSerializer<N>getNamespaceSerializer()intnumEventTimeTimers()intnumEventTimeTimers(N namespace)intnumProcessingTimeTimers()intnumProcessingTimeTimers(N namespace)voidregisterEventTimeTimer(N namespace, long time)Registers a timer to be fired when event time watermark passes the given time.voidregisterProcessingTimeTimer(N namespace, long time)Registers a timer to be fired when processing time passes the given time.voidrestoreTimersForKeyGroup(InternalTimersSnapshot<?,?> restoredSnapshot, int keyGroupIdx)Restore the timers (both processing and event time ones) for a givenkeyGroupIdx.InternalTimersSnapshot<K,N>snapshotTimersForKeyGroup(int keyGroupIdx)Snapshots the timers (both processing and event time ones) for a givenkeyGroupIdx.voidstartTimerService(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerTarget)Starts the localInternalTimerServiceImplby: Setting thekeySerializedandnamespaceSerializerfor the timers it will contain.
-
-
-
Method Detail
-
startTimerService
public void startTimerService(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerTarget)
Starts the localInternalTimerServiceImplby:- Setting the
keySerializedandnamespaceSerializerfor the timers it will contain. - Setting the
triggerTargetwhich contains the action to be performed when a timer fires. - Re-registering timers that were retrieved after recovering from a node failure, if any.
This method can be called multiple times, as long as it is called with the same serializers.
- Setting the
-
currentProcessingTime
public long currentProcessingTime()
Description copied from interface:InternalTimerServiceReturns the current processing time.- Specified by:
currentProcessingTimein interfaceInternalTimerService<K>
-
currentWatermark
public long currentWatermark()
Description copied from interface:InternalTimerServiceReturns the current event-time watermark.- Specified by:
currentWatermarkin interfaceInternalTimerService<K>
-
registerProcessingTimeTimer
public void registerProcessingTimeTimer(N namespace, long time)
Description copied from interface:InternalTimerServiceRegisters a timer to be fired when processing time passes the given time. The namespace you pass here will be provided when the timer fires.- Specified by:
registerProcessingTimeTimerin interfaceInternalTimerService<K>
-
registerEventTimeTimer
public void registerEventTimeTimer(N namespace, long time)
Description copied from interface:InternalTimerServiceRegisters a timer to be fired when event time watermark passes the given time. The namespace you pass here will be provided when the timer fires.- Specified by:
registerEventTimeTimerin interfaceInternalTimerService<K>
-
deleteProcessingTimeTimer
public void deleteProcessingTimeTimer(N namespace, long time)
Description copied from interface:InternalTimerServiceDeletes the timer for the given key and namespace.- Specified by:
deleteProcessingTimeTimerin interfaceInternalTimerService<K>
-
deleteEventTimeTimer
public void deleteEventTimeTimer(N namespace, long time)
Description copied from interface:InternalTimerServiceDeletes the timer for the given key and namespace.- Specified by:
deleteEventTimeTimerin interfaceInternalTimerService<K>
-
forEachEventTimeTimer
public void forEachEventTimeTimer(org.apache.flink.util.function.BiConsumerWithException<N,Long,Exception> consumer) throws Exception
Description copied from interface:InternalTimerServicePerforms an action for each registered timer. The timer service will set the key context for the timers key before invoking the action.- Specified by:
forEachEventTimeTimerin interfaceInternalTimerService<K>- Throws:
Exception
-
forEachProcessingTimeTimer
public void forEachProcessingTimeTimer(org.apache.flink.util.function.BiConsumerWithException<N,Long,Exception> consumer) throws Exception
Description copied from interface:InternalTimerServicePerforms an action for each registered timer. The timer service will set the key context for the timers key before invoking the action.- Specified by:
forEachProcessingTimeTimerin interfaceInternalTimerService<K>- Throws:
Exception
-
snapshotTimersForKeyGroup
public InternalTimersSnapshot<K,N> snapshotTimersForKeyGroup(int keyGroupIdx)
Snapshots the timers (both processing and event time ones) for a givenkeyGroupIdx.- Parameters:
keyGroupIdx- the id of the key-group to be put in the snapshot.- Returns:
- a snapshot containing the timers for the given key-group, and the serializers for them
-
getKeySerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
-
getNamespaceSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<N> getNamespaceSerializer()
-
restoreTimersForKeyGroup
public void restoreTimersForKeyGroup(InternalTimersSnapshot<?,?> restoredSnapshot, int keyGroupIdx)
Restore the timers (both processing and event time ones) for a givenkeyGroupIdx.- Parameters:
restoredSnapshot- the restored snapshot containing the key-group's timers, and the serializers that were used to write themkeyGroupIdx- the id of the key-group to be put in the snapshot.
-
numProcessingTimeTimers
@VisibleForTesting public int numProcessingTimeTimers()
-
numEventTimeTimers
@VisibleForTesting public int numEventTimeTimers()
-
numProcessingTimeTimers
@VisibleForTesting public int numProcessingTimeTimers(N namespace)
-
numEventTimeTimers
@VisibleForTesting public int numEventTimeTimers(N namespace)
-
-