Class DefaultTimerService<K>
- java.lang.Object
-
- org.apache.flink.runtime.taskexecutor.slot.DefaultTimerService<K>
-
- Type Parameters:
K- Type of the key
- All Implemented Interfaces:
TimerService<K>
public class DefaultTimerService<K> extends Object implements TimerService<K>
Service to register timeouts for a given key. The timeouts are identified by a ticket so that newly registered timeouts for the same key can be distinguished from older timeouts.
-
-
Constructor Summary
Constructors Constructor Description DefaultTimerService(ScheduledExecutorService scheduledExecutorService, long shutdownTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisValid(K key, UUID ticket)Check whether the timeout for the given key and ticket is still valid (not yet unregistered and not yet overwritten).voidregisterTimeout(K key, long delay, TimeUnit unit)Register a timeout for the given key which shall occur in the given delay.voidstart(TimeoutListener<K> initialTimeoutListener)Starts this timer service.voidstop()Stops this timer service.protected voidunregisterAllTimeouts()Unregister all timeouts.voidunregisterTimeout(K key)Unregister the timeout for the given key.
-
-
-
Constructor Detail
-
DefaultTimerService
public DefaultTimerService(ScheduledExecutorService scheduledExecutorService, long shutdownTimeout)
-
-
Method Detail
-
start
public void start(TimeoutListener<K> initialTimeoutListener)
Description copied from interface:TimerServiceStarts this timer service.- Specified by:
startin interfaceTimerService<K>- Parameters:
initialTimeoutListener- listener for timeouts that have fired
-
stop
public void stop()
Description copied from interface:TimerServiceStops this timer service.- Specified by:
stopin interfaceTimerService<K>
-
registerTimeout
public void registerTimeout(K key, long delay, TimeUnit unit)
Description copied from interface:TimerServiceRegister a timeout for the given key which shall occur in the given delay.- Specified by:
registerTimeoutin interfaceTimerService<K>- Parameters:
key- for which to register the timeoutdelay- until the timeoutunit- of the timeout delay
-
unregisterTimeout
public void unregisterTimeout(K key)
Description copied from interface:TimerServiceUnregister the timeout for the given key.- Specified by:
unregisterTimeoutin interfaceTimerService<K>- Parameters:
key- for which to unregister the timeout
-
unregisterAllTimeouts
protected void unregisterAllTimeouts()
Unregister all timeouts.
-
isValid
public boolean isValid(K key, UUID ticket)
Description copied from interface:TimerServiceCheck whether the timeout for the given key and ticket is still valid (not yet unregistered and not yet overwritten).- Specified by:
isValidin interfaceTimerService<K>- Parameters:
key- for which to check the timeoutticket- of the timeout- Returns:
- True if the timeout ticket is still valid; otherwise false
-
-