Class ExponentialBackoff

  • All Implemented Interfaces:
    BackoffSupplier

    public final class ExponentialBackoff
    extends Object
    implements BackoffSupplier
    An implementation of BackoffSupplier which uses a simple formula, multiplying the previous delay with an increasing multiplier and adding some jitter to avoid multiple clients polling at the same time even with back off.

    The next delay is calculated as:

     max(min(maxDelay, currentDelay * backoffFactor), minDelay) + (rand(0.0, 1.0) *
     (currentDelay * jitterFactor) + (currentDelay * -jitterFactor)) 
    • Constructor Detail

      • ExponentialBackoff

        public ExponentialBackoff​(long maxDelay,
                                  long minDelay,
                                  double backoffFactor,
                                  double jitterFactor,
                                  Random random)
    • Method Detail

      • supplyRetryDelay

        public long supplyRetryDelay​(long currentRetryDelay)
        Description copied from interface: BackoffSupplier
        Returns the delay before the next retry. The delay should be specified in milliseconds.
        Specified by:
        supplyRetryDelay in interface BackoffSupplier
        Parameters:
        currentRetryDelay - the last used retry delay
        Returns:
        the new retry delay