Class ExponentialBackOffWithDeadlinePolicy

  • All Implemented Interfaces:
    RetryPolicy

    public class ExponentialBackOffWithDeadlinePolicy
    extends java.lang.Object
    implements RetryPolicy
    Backoff time determined based as a multiple of baseBackoffTime. The multiple value depends on retryCount. If the retry schedule exceeds the deadline, we schedule a final attempt exactly at the deadline.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Object

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

      • RETRY_BACKOFF

        static final int[] RETRY_BACKOFF
    • Constructor Detail

      • ExponentialBackOffWithDeadlinePolicy

        public ExponentialBackOffWithDeadlinePolicy​(long baseBackoffTime,
                                                    long deadline,
                                                    int maxRetries)
    • Method Detail

      • 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)