public class HeapInternalTimerService<K,N> extends Object implements InternalTimerService<N>, ProcessingTimeCallback
InternalTimerService
that stores timers on the Java heap.Constructor and Description |
---|
HeapInternalTimerService(int totalKeyGroups,
KeyGroupsList localKeyGroupRange,
KeyContext keyContext,
ProcessingTimeService processingTimeService) |
Modifier and Type | Method and Description |
---|---|
void |
advanceWatermark(long time) |
long |
currentProcessingTime()
Returns the current processing time.
|
long |
currentWatermark()
Returns the current event-time watermark.
|
void |
deleteEventTimeTimer(N namespace,
long time)
Deletes the timer for the given key and namespace.
|
void |
deleteProcessingTimeTimer(N namespace,
long time)
Deletes the timer for the given key and namespace.
|
Set<InternalTimer<K,N>>[] |
getEventTimeTimersPerKeyGroup() |
int |
getLocalKeyGroupRangeStartIdx() |
Set<InternalTimer<K,N>>[] |
getProcessingTimeTimersPerKeyGroup() |
int |
numEventTimeTimers() |
int |
numEventTimeTimers(N namespace) |
int |
numProcessingTimeTimers() |
int |
numProcessingTimeTimers(N namespace) |
void |
onProcessingTime(long time)
This method is invoked with the timestamp for which the trigger was scheduled.
|
void |
registerEventTimeTimer(N namespace,
long time)
Registers a timer to be fired when processing time passes the given time.
|
void |
registerProcessingTimeTimer(N namespace,
long time)
Registers a timer to be fired when processing time passes the given time.
|
void |
restoreTimersForKeyGroup(InternalTimersSnapshot<?,?> restoredTimersSnapshot,
int keyGroupIdx)
Restore the timers (both processing and event time ones) for a given
keyGroupIdx . |
InternalTimersSnapshot<K,N> |
snapshotTimersForKeyGroup(int keyGroupIdx)
Snapshots the timers (both processing and event time ones) for a given
keyGroupIdx . |
void |
startTimerService(TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer,
Triggerable<K,N> triggerTarget)
Starts the local
HeapInternalTimerService by:
Setting the keySerialized and namespaceSerializer for the timers it will contain.
Setting the triggerTarget which contains the action to be performed when a timer fires.
Re-registering timers that were retrieved after recoveting from a node failure, if any.
This method can be called multiple times, as long as it is called with the same serializers. |
public HeapInternalTimerService(int totalKeyGroups, KeyGroupsList localKeyGroupRange, KeyContext keyContext, ProcessingTimeService processingTimeService)
public void startTimerService(TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, Triggerable<K,N> triggerTarget)
HeapInternalTimerService
by:
keySerialized
and namespaceSerializer
for the timers it will contain.triggerTarget
which contains the action to be performed when a timer fires.public long currentProcessingTime()
InternalTimerService
currentProcessingTime
in interface InternalTimerService<N>
public long currentWatermark()
InternalTimerService
currentWatermark
in interface InternalTimerService<N>
public void registerProcessingTimeTimer(N namespace, long time)
InternalTimerService
registerProcessingTimeTimer
in interface InternalTimerService<N>
public void registerEventTimeTimer(N namespace, long time)
InternalTimerService
registerEventTimeTimer
in interface InternalTimerService<N>
public void deleteProcessingTimeTimer(N namespace, long time)
InternalTimerService
deleteProcessingTimeTimer
in interface InternalTimerService<N>
public void deleteEventTimeTimer(N namespace, long time)
InternalTimerService
deleteEventTimeTimer
in interface InternalTimerService<N>
public void onProcessingTime(long time) throws Exception
ProcessingTimeCallback
If the triggering is delayed for whatever reason (trigger timer was blocked, JVM stalled due to a garbage collection), the timestamp supplied to this function will still be the original timestamp for which the trigger was scheduled.
onProcessingTime
in interface ProcessingTimeCallback
time
- The timestamp for which the trigger event was scheduled.Exception
public InternalTimersSnapshot<K,N> snapshotTimersForKeyGroup(int keyGroupIdx)
keyGroupIdx
.keyGroupIdx
- the id of the key-group to be put in the snapshot.public void restoreTimersForKeyGroup(InternalTimersSnapshot<?,?> restoredTimersSnapshot, int keyGroupIdx) throws IOException
keyGroupIdx
.restoredTimersSnapshot
- 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.IOException
public int numProcessingTimeTimers()
public int numEventTimeTimers()
public int numProcessingTimeTimers(N namespace)
public int numEventTimeTimers(N namespace)
@VisibleForTesting public int getLocalKeyGroupRangeStartIdx()
@VisibleForTesting public Set<InternalTimer<K,N>>[] getEventTimeTimersPerKeyGroup()
@VisibleForTesting public Set<InternalTimer<K,N>>[] getProcessingTimeTimersPerKeyGroup()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.