Class ExponentialBackoffRetry

java.lang.Object
org.apache.curator.retry.ExponentialBackoffRetry
All Implemented Interfaces:
RetryPolicy
Direct Known Subclasses:
BoundedExponentialBackoffRetry

public class ExponentialBackoffRetry
extends java.lang.Object
Retry policy that retries a set number of times with increasing sleep time between retries
  • Constructor Summary

    Constructors 
    Constructor Description
    ExponentialBackoffRetry​(int baseSleepTimeMs, int maxRetries)  
    ExponentialBackoffRetry​(int baseSleepTimeMs, int maxRetries, int maxSleepMs)  
  • Method Summary

    Modifier and Type Method Description
    boolean allowRetry​(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
    Called when an operation has failed for some reason.
    int getBaseSleepTimeMs()  
    int getN()  
    protected long getSleepTimeMs​(int retryCount, long elapsedTimeMs)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.curator.RetryPolicy

    allowRetry
  • Constructor Details

    • ExponentialBackoffRetry

      public ExponentialBackoffRetry​(int baseSleepTimeMs, int maxRetries)
      Parameters:
      baseSleepTimeMs - initial amount of time to wait between retries
      maxRetries - max number of times to retry
    • ExponentialBackoffRetry

      public ExponentialBackoffRetry​(int baseSleepTimeMs, int maxRetries, int maxSleepMs)
      Parameters:
      baseSleepTimeMs - initial amount of time to wait between retries
      maxRetries - max number of times to retry
      maxSleepMs - max time in ms to sleep on each retry
  • Method Details

    • getBaseSleepTimeMs

      public int getBaseSleepTimeMs()
    • getSleepTimeMs

      protected long getSleepTimeMs​(int retryCount, long elapsedTimeMs)
    • getN

      public int getN()
    • allowRetry

      public boolean allowRetry​(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
      Description copied from interface: RetryPolicy
      Called when an operation has failed for some reason. This method should return true to make another attempt.
      Specified by:
      allowRetry in interface RetryPolicy
      Parameters:
      retryCount - the number of times retried so far (0 the first time)
      elapsedTimeMs - the elapsed time in ms since the operation was attempted
      sleeper - use this to sleep - DO NOT call Thread.sleep
      Returns:
      true/false