Interface TimerService


public interface TimerService
Timer service providing API to schedule timers in the Cluster.
  • Field Details

  • Method Details

    • poll

      int poll(long now)
      Poll for expired timers. For each expired timer it invokes TimerService.TimerHandler.onTimerEvent(long) on the TimerService.TimerHandler that was provided upon creation of this TimerService instance. Poll can be terminated early if POLL_LIMIT is reached or if TimerService.TimerHandler.onTimerEvent(long) returns false.
      Parameters:
      now - current time.
      Returns:
      number of timers expired, never exceeds POLL_LIMIT.
    • scheduleTimerForCorrelationId

      void scheduleTimerForCorrelationId(long correlationId, long deadline)
      Schedule timer with the given correlationId and deadline.
      Parameters:
      correlationId - to associate with the timer.
      deadline - when the timer expires.
    • cancelTimerByCorrelationId

      boolean cancelTimerByCorrelationId(long correlationId)
      Cancels timer by its correlationId.
      Parameters:
      correlationId - of the timer to cancel.
      Returns:
      true if the timer was cancelled.
    • snapshot

      void snapshot(TimerService.TimerSnapshotTaker snapshotTaker)
      Takes a snapshot of the timer service state, i.e. serializes all non-expired timers.
      Parameters:
      snapshotTaker - to take a snapshot.
    • currentTime

      void currentTime(long now)
      Set the current time from the Cluster in case the underlying implementation depends on it.
      Parameters:
      now - the current time.