Class Retry.DelayingRetryPolicy

  • All Implemented Interfaces:
    Enclosing interface:

    public static class Retry.DelayingRetryPolicy
    extends Object
    implements Retry.RetryPolicy
    A retry policy that prolongs the delays between retries by a defined factor.

    Consider the following setup:

    • calls = 4
    • delayMillis = 100
    • factor = 2.0
    The following delays will be used for each call:
    • Initial call - always immediate (not handled by retry policy)
    • First retry - 100 millis
    • Second retry - 200 millis (previous delay * factor)
    • Third retry - 400 millis (previous delay * factor)
    • Method Detail

      • noDelay

        public static Retry.DelayingRetryPolicy noDelay​(int calls)
        Create a retry policy with no delays and with the specified number of calls.
        calls - number of calls to execute (retries + initial call)
        a no delay retry policy
      • nextDelayMillis

        public Optional<Long> nextDelayMillis​(long firstCallMillis,
                                              long lastDelay,
                                              int call)
        Description copied from interface: Retry.RetryPolicy
        Return next delay in milliseconds, or an empty optional to finish retries.
        Specified by:
        nextDelayMillis in interface Retry.RetryPolicy
        firstCallMillis - milliseconds recorded before the first call using System.currentTimeMillis()
        lastDelay - last delay that was used (0 for the first failed call)
        call - call index (0 for the first failed call)
        how long to wait before trying again, or empty to notify this is the end of retries