Class TimerGraphStageLogic

java.lang.Object
org.apache.pekko.stream.stage.GraphStageLogic
org.apache.pekko.stream.stage.TimerGraphStageLogic
Direct Known Subclasses:
TimerGraphStageLogicWithLogging

public abstract class TimerGraphStageLogic extends GraphStageLogic
Provides timer related facilities to a GraphStageLogic.

To be thread safe the methods of this class must only be called from either the constructor of the graph operator during materialization or one of the methods invoked by the graph operator machinery, such as onPush and onPull.

  • Constructor Details

    • TimerGraphStageLogic

      public TimerGraphStageLogic(Shape _shape)
  • Method Details

    • afterPostStop

      protected void afterPostStop()
      Description copied from class: GraphStageLogic
      INTERNAL API
      Overrides:
      afterPostStop in class GraphStageLogic
    • cancelTimer

      protected final void cancelTimer(Object timerKey)
      Cancel timer, ensuring that the onTimer(java.lang.Object) is not subsequently called.

      Parameters:
      timerKey - key of the timer to cancel
    • isTimerActive

      protected final boolean isTimerActive(Object timerKey)
      Inquire whether the timer is still active. Returns true unless the timer does not exist, has previously been canceled or if it was a single-shot timer that was already triggered.
    • onTimer

      protected void onTimer(Object timerKey) throws Exception
      Will be called when the scheduled timer is triggered.

      Parameters:
      timerKey - key of the scheduled timer
      Throws:
      Exception
    • scheduleAtFixedRate

      protected final void scheduleAtFixedRate(Object timerKey, scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration interval)
      Schedule timer to call onTimer(java.lang.Object) periodically with the given interval after the specified initial delay. Any existing timer with the same key will automatically be canceled before adding the new timer.
    • scheduleAtFixedRate

      protected final void scheduleAtFixedRate(Object timerKey, Duration initialDelay, Duration interval)
      Schedule timer to call onTimer(java.lang.Object) periodically with the given interval after the specified initial delay. Any existing timer with the same key will automatically be canceled before adding the new timer.
    • scheduleOnce

      protected final void scheduleOnce(Object timerKey, scala.concurrent.duration.FiniteDuration delay)
      Schedule timer to call onTimer(java.lang.Object) after given delay. Any existing timer with the same key will automatically be canceled before adding the new timer.
    • scheduleOnce

      protected final void scheduleOnce(Object timerKey, Duration delay)
      Schedule timer to call onTimer(java.lang.Object) after given delay. Any existing timer with the same key will automatically be canceled before adding the new timer.
    • scheduleWithFixedDelay

      protected final void scheduleWithFixedDelay(Object timerKey, scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration delay)
      Schedule timer to call onTimer(java.lang.Object) periodically with the given delay after the specified initial delay. Any existing timer with the same key will automatically be canceled before adding the new timer.
    • scheduleWithFixedDelay

      protected final void scheduleWithFixedDelay(Object timerKey, Duration initialDelay, Duration interval)
      Schedule timer to call onTimer(java.lang.Object) periodically with the given delay after the specified initial delay. Any existing timer with the same key will automatically be canceled before adding the new timer.