com.alarmpoint.integrationagent.exceptions.retriable

## Class ExponentialDelayPolicy

- java.lang.Object
- - com.alarmpoint.integrationagent.exceptions.retriable.ExponentialDelayPolicy

- All Implemented Interfaces:
    DelayPolicy

      public class ExponentialDelayPolicy
      extends java.lang.Object
      implements DelayPolicy

  A policy that specifies an exponentially increasing delay between retry attempts.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExponentialDelayPolicy(long delayMillis, long maxDelayMillis, double growthFactor)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getDelay(int numAttempts, long lastDelay)` Gets the minimum amount of time that must elapse before the next retry attempt.
    `java.lang.String` | `toString()` Returns a string of the form: "10 seconds after first attempt, increasing by 2x for each additional attempt up to 300 seconds".

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ExponentialDelayPolicy

          public ExponentialDelayPolicy(long delayMillis,
                                        long maxDelayMillis,
                                        double growthFactor)

      Default constructor.
      Parameters:
        `delayMillis` - - the minimum delay (in milliseconds) for the first retry attempt; must be > 0
        `maxDelayMillis` - - the maximum cap (in milliseconds) applied to the computed delay; must be >= delayMillis
        `growthFactor` - - the exponential growth factor applied to the previous delay in order to compute the next delay; must be >= 1.0 with `1.0` resulting in a fixed delay

  - ### Method Detail

    - #### getDelay

          public long getDelay(int numAttempts,
                               long lastDelay)

      Gets the minimum amount of time that must elapse before the next retry attempt.
      Specified by:
        `getDelay` in interface `DelayPolicy`
      Parameters:
        `numAttempts` - - the number of previous attempts (including first attempt and retries); assumed to be >= 1
        `lastDelay` - - the delay (in milliseconds) returned by the previous call to this method (i.e., with `numAttempts-1`); -1 if not previously code (i.e., when `numAttempts==0`
      Returns:
        a non-negative integer indicating the delay in milliseconds

    - #### toString

          public java.lang.String toString()

      Returns a string of the form: "10 seconds after first attempt, increasing by 2x for each additional attempt up to 300 seconds".
      Specified by:
        `toString` in interface `DelayPolicy`
      Overrides:
        `toString` in class `java.lang.Object`