Class SystemProcessingTimeService
- java.lang.Object
-
- org.apache.flink.streaming.runtime.tasks.SystemProcessingTimeService
-
- All Implemented Interfaces:
org.apache.flink.api.common.operators.ProcessingTimeService,ProcessingTimeService,TimerService
@Internal public class SystemProcessingTimeService extends Object implements TimerService
ATimerServicewhich assigns as current processing time the result of callingSystem.currentTimeMillis()and registers timers using aScheduledThreadPoolExecutor.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfinalize()org.apache.flink.util.clock.ClockgetClock()ReturnsClockassociated with this timer service.booleanisTerminated()Returns true if the service has been shut down, false otherwise.CompletableFuture<Void>quiesce()This method puts the service into a state where it does not register new timers, but returns for each call toProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback)orProcessingTimeService.scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback, long, long)a "mock" future and the "mock" future will be never completed.ScheduledFuture<?>registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback)Registers a task to be executed no sooner than timetimestamp, but without strong guarantees of order.ScheduledFuture<?>scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)Registers a task to be executed repeatedly at a fixed rate.ScheduledFuture<?>scheduleWithFixedDelay(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)Registers a task to be executed repeatedly with a fixed delay.voidshutdownService()Shuts down and clean up the timer service provider hard and immediately.booleanshutdownServiceUninterruptible(long timeoutMs)Shuts down and clean up the timer service provider hard and immediately.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.streaming.runtime.tasks.ProcessingTimeService
getCurrentProcessingTime
-
-
-
-
Method Detail
-
getClock
public org.apache.flink.util.clock.Clock getClock()
Description copied from interface:ProcessingTimeServiceReturnsClockassociated with this timer service.- Specified by:
getClockin interfaceProcessingTimeService
-
registerTimer
public ScheduledFuture<?> registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback)
Registers a task to be executed no sooner than timetimestamp, but without strong guarantees of order.- Specified by:
registerTimerin interfaceorg.apache.flink.api.common.operators.ProcessingTimeService- Parameters:
timestamp- Time when the task is to be enabled (in processing time)callback- The task to be executed- Returns:
- The future that represents the scheduled task. This always returns some future, even if the timer was shut down
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
Description copied from interface:ProcessingTimeServiceRegisters a task to be executed repeatedly at a fixed rate.This call behaves similar to
ScheduledExecutor.scheduleAtFixedRate(Runnable, long, long, TimeUnit).- Specified by:
scheduleAtFixedRatein interfaceProcessingTimeService- Parameters:
callback- to be executed after the initial delay and then after each periodinitialDelay- initial delay to start executing callbackperiod- after the initial delay after which the callback is executed- Returns:
- Scheduled future representing the task to be executed repeatedly
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
Description copied from interface:ProcessingTimeServiceRegisters a task to be executed repeatedly with a fixed delay.This call behaves similar to
ScheduledExecutor.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).- Specified by:
scheduleWithFixedDelayin interfaceProcessingTimeService- Parameters:
callback- to be executed after the initial delay and then after each periodinitialDelay- initial delay to start executing callbackperiod- after the initial delay after which the callback is executed- Returns:
- Scheduled future representing the task to be executed repeatedly
-
isTerminated
public boolean isTerminated()
Description copied from interface:TimerServiceReturns true if the service has been shut down, false otherwise.- Specified by:
isTerminatedin interfaceTimerService
-
quiesce
public CompletableFuture<Void> quiesce()
Description copied from interface:ProcessingTimeServiceThis method puts the service into a state where it does not register new timers, but returns for each call toProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback)orProcessingTimeService.scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback, long, long)a "mock" future and the "mock" future will be never completed. Furthermore, the timers registered before are prevented from firing, but the timers in running are allowed to finish.If no timer is running, the quiesce-completed future is immediately completed and returned. Otherwise, the future returned will be completed when all running timers have finished.
- Specified by:
quiescein interfaceProcessingTimeService
-
shutdownService
public void shutdownService()
Description copied from interface:TimerServiceShuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call toProcessingTimeService.registerTimer(long, ProcessingTimeCallback)will result in a hard exception.- Specified by:
shutdownServicein interfaceTimerService
-
shutdownServiceUninterruptible
public boolean shutdownServiceUninterruptible(long timeoutMs)
Description copied from interface:TimerServiceShuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call toProcessingTimeService.registerTimer(long, ProcessingTimeCallback)will result in a hard exception. This call cannot be interrupted and will block until the shutdown is completed or the timeout is exceeded.- Specified by:
shutdownServiceUninterruptiblein interfaceTimerService- Parameters:
timeoutMs- timeout for blocking on the service shutdown in milliseconds.- Returns:
- returns true iff the shutdown was completed.
-
-