Interface RetryPolicy

All Known Implementing Classes:
BoundExponentialBackoffRetryPolicy, ExponentialBackoffRetryPolicy, ExponentialBackOffWithDeadlinePolicy

public interface RetryPolicy
Interface of the policy to use when retrying operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    allowRetry(int retryCount, long elapsedRetryTime)
    Called when retrying an operation failed for some reason.
    long
    nextRetryWaitTime(int retryCount, long elapsedRetryTime)
    Called before making an attempt to retry a failed operation.
  • Method Details

    • allowRetry

      boolean allowRetry(int retryCount, long elapsedRetryTime)
      Called when retrying an operation failed for some reason. Return true if another attempt is allowed to make.
      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

      long nextRetryWaitTime(int retryCount, long elapsedRetryTime)
      Called before making an attempt to retry a failed operation. Return 0 if an attempt needs to be made immediately.
      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)