Class ExponentialBackoffRetryPolicy

java.lang.Object
org.apache.bookkeeper.zookeeper.ExponentialBackoffRetryPolicy
All Implemented Interfaces:
RetryPolicy
Direct Known Subclasses:
BoundExponentialBackoffRetryPolicy

public class ExponentialBackoffRetryPolicy extends Object implements RetryPolicy
A retry policy implementation that backoff retries exponentially.
  • Constructor Details

    • ExponentialBackoffRetryPolicy

      public ExponentialBackoffRetryPolicy(long baseBackoffTime, int maxRetries)
  • Method Details

    • allowRetry

      public boolean allowRetry(int retryCount, long elapsedRetryTime)
      Description copied from interface: RetryPolicy
      Called when retrying an operation failed for some reason. Return true if another attempt is allowed to make.
      Specified by:
      allowRetry in interface RetryPolicy
      Parameters:
      retryCount - The number of times retried so far (1 for the first time).
      elapsedRetryTime - The elapsed time since the operation attempted. (in milliseconds)
      Returns:
      true if anther attempt is allowed to make. otherwise, false.
    • nextRetryWaitTime

      public long nextRetryWaitTime(int retryCount, long elapsedRetryTime)
      Description copied from interface: RetryPolicy
      Called before making an attempt to retry a failed operation. Return 0 if an attempt needs to be made immediately.
      Specified by:
      nextRetryWaitTime in interface RetryPolicy
      Parameters:
      retryCount - The number of times retried so far (0 for the first time).
      elapsedRetryTime - The elapsed time since the operation attempted. (in milliseconds)
      Returns:
      the elapsed time that the attempt needs to wait before retrying. (in milliseconds)