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
A TimerService which assigns as current processing time the result of calling System.currentTimeMillis() and registers timers using a ScheduledThreadPoolExecutor.
  • Method Details

    • getClock

      public org.apache.flink.util.clock.Clock getClock()
      Description copied from interface: ProcessingTimeService
      Returns Clock associated with this timer service.
      Specified by:
      getClock in interface ProcessingTimeService
    • registerTimer

      public ScheduledFuture<?> registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback)
      Registers a task to be executed no sooner than time timestamp, but without strong guarantees of order.
      Specified by:
      registerTimer in interface org.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: ProcessingTimeService
      Registers a task to be executed repeatedly at a fixed rate.

      This call behaves similar to ScheduledExecutor.scheduleAtFixedRate(Runnable, long, long, TimeUnit).

      Specified by:
      scheduleAtFixedRate in interface ProcessingTimeService
      Parameters:
      callback - to be executed after the initial delay and then after each period
      initialDelay - initial delay to start executing callback
      period - 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: ProcessingTimeService
      Registers a task to be executed repeatedly with a fixed delay.

      This call behaves similar to ScheduledExecutor.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).

      Specified by:
      scheduleWithFixedDelay in interface ProcessingTimeService
      Parameters:
      callback - to be executed after the initial delay and then after each period
      initialDelay - initial delay to start executing callback
      period - 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: TimerService
      Returns true if the service has been shut down, false otherwise.
      Specified by:
      isTerminated in interface TimerService
    • quiesce

      public CompletableFuture<Void> quiesce()
      Description copied from interface: ProcessingTimeService
      This method puts the service into a state where it does not register new timers, but returns for each call to ProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback) or ProcessingTimeService.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:
      quiesce in interface ProcessingTimeService
    • shutdownService

      public void shutdownService()
      Description copied from interface: TimerService
      Shuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call to ProcessingTimeService.registerTimer(long, ProcessingTimeCallback) will result in a hard exception.
      Specified by:
      shutdownService in interface TimerService
    • shutdownServiceUninterruptible

      public boolean shutdownServiceUninterruptible(long timeoutMs)
      Description copied from interface: TimerService
      Shuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call to ProcessingTimeService.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:
      shutdownServiceUninterruptible in interface TimerService
      Parameters:
      timeoutMs - timeout for blocking on the service shutdown in milliseconds.
      Returns:
      returns true iff the shutdown was completed.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable