Class BeforeRetryExponentialBackoffTask

  • All Implemented Interfaces:
    java.lang.Runnable

    public class BeforeRetryExponentialBackoffTask
    extends java.lang.Object
    implements java.lang.Runnable
    A backoff task for use in a retry -function, -supplier, or -task. This should be used as the beforeRetry hook. Upon each execution, the amount of time to wait before retrying the function call is doubled. This class maintains an internal state; we recommend creating a new instance for each use.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long backoff  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) long currentBackoff()  
      void run()
      This method causes the current thread to sleep for a duration which doubles after each successive call.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • backoff

        private long backoff
    • Constructor Detail

      • BeforeRetryExponentialBackoffTask

        public BeforeRetryExponentialBackoffTask​(long backoffMillis)

        Constructor for BeforeRetryExponentialBackoffTask.

        Parameters:
        backoffMillis - the amount of time to wait, in milliseconds before retrying the first time. This is doubled for each subsequent retry. This parameter must be above zero.
    • Method Detail

      • run

        public void run()
        This method causes the current thread to sleep for a duration which doubles after each successive call. InterruptedExceptions are wrapped before being rethrown in a RuntimeException.
        Specified by:
        run in interface java.lang.Runnable
      • currentBackoff

        long currentBackoff()