org.springframework.util.backoff

## 类 ExponentialBackOff

- java.lang.Object
- - org.springframework.util.backoff.ExponentialBackOff

- 所有已实现的接口:
    BackOff

      public class ExponentialBackOff
      extends Object
      implements BackOff

  Implementation of `BackOff` that increases the back off period for each retry attempt. When the interval has reached the `max interval`, it is no longer increased. Stops retrying once the `max elapsed time` has been reached.

  Example: The default interval is 2000L ms, the default multiplier is 1.5, and the default max interval is 30000L. For 10 attempts the sequence will be as follows:

       request#     back off

        1              2000
        2              3000
        3              4500
        4              6750
        5             10125
        6             15187
        7             22780
        8             30000
        9             30000
       10             30000

  Note that the default max elapsed time is `Long.MAX_VALUE`. Use `setMaxElapsedTime(long)` to limit the maximum length of time that an instance should accumulate before returning `BackOffExecution.STOP`.

  从以下版本开始:
    4.1
  作者:
    Stephane Nicoll

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static long` | `DEFAULT_INITIAL_INTERVAL` The default initial interval.
    `static long` | `DEFAULT_MAX_ELAPSED_TIME` The default maximum elapsed time.
    `static long` | `DEFAULT_MAX_INTERVAL` The default maximum back off time.
    `static double` | `DEFAULT_MULTIPLIER` The default multiplier (increases the interval by 50%).

  - ### 构造器概要

    构造器
    构造器和说明
    `ExponentialBackOff()` Create an instance with the default settings.
    `ExponentialBackOff(long initialInterval, double multiplier)` Create an instance with the supplied settings.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `long` | `getInitialInterval()` Return the initial interval in milliseconds.
    `long` | `getMaxElapsedTime()` Return the maximum elapsed time in milliseconds after which a call to `BackOffExecution.nextBackOff()` returns `BackOffExecution.STOP`.
    `long` | `getMaxInterval()` Return the maximum back off time.
    `double` | `getMultiplier()` Return the value to multiply the current interval by for each retry attempt.
    `void` | `setInitialInterval(long initialInterval)` The initial interval in milliseconds.
    `void` | `setMaxElapsedTime(long maxElapsedTime)` The maximum elapsed time in milliseconds after which a call to `BackOffExecution.nextBackOff()` returns `BackOffExecution.STOP`.
    `void` | `setMaxInterval(long maxInterval)` The maximum back off time.
    `void` | `setMultiplier(double multiplier)` The value to multiply the current interval by for each retry attempt.
    `BackOffExecution` | `start()` Start a new back off execution.

    - ### 从类继承的方法 java.lang.Object

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

- - ### 字段详细资料

    - #### DEFAULT_INITIAL_INTERVAL

          public static final long DEFAULT_INITIAL_INTERVAL

      The default initial interval.
      另请参阅:
        常量字段值

    - #### DEFAULT_MULTIPLIER

          public static final double DEFAULT_MULTIPLIER

      The default multiplier (increases the interval by 50%).
      另请参阅:
        常量字段值

    - #### DEFAULT_MAX_INTERVAL

          public static final long DEFAULT_MAX_INTERVAL

      The default maximum back off time.
      另请参阅:
        常量字段值

    - #### DEFAULT_MAX_ELAPSED_TIME

          public static final long DEFAULT_MAX_ELAPSED_TIME

      The default maximum elapsed time.
      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### ExponentialBackOff

          public ExponentialBackOff()

      Create an instance with the default settings.
      另请参阅:
        `DEFAULT_INITIAL_INTERVAL`, `DEFAULT_MULTIPLIER`, `DEFAULT_MAX_INTERVAL`, `DEFAULT_MAX_ELAPSED_TIME`

    - #### ExponentialBackOff

          public ExponentialBackOff(long initialInterval,
                                    double multiplier)

      Create an instance with the supplied settings.
      参数:
        `initialInterval` - the initial interval in milliseconds
        `multiplier` - the multiplier (should be greater than or equal to 1)

  - ### 方法详细资料

    - #### setInitialInterval

          public void setInitialInterval(long initialInterval)

      The initial interval in milliseconds.

    - #### getInitialInterval

          public long getInitialInterval()

      Return the initial interval in milliseconds.

    - #### setMultiplier

          public void setMultiplier(double multiplier)

      The value to multiply the current interval by for each retry attempt.

    - #### getMultiplier

          public double getMultiplier()

      Return the value to multiply the current interval by for each retry attempt.

    - #### setMaxInterval

          public void setMaxInterval(long maxInterval)

      The maximum back off time.

    - #### getMaxInterval

          public long getMaxInterval()

      Return the maximum back off time.

    - #### setMaxElapsedTime

          public void setMaxElapsedTime(long maxElapsedTime)

      The maximum elapsed time in milliseconds after which a call to `BackOffExecution.nextBackOff()` returns `BackOffExecution.STOP`.

    - #### getMaxElapsedTime

          public long getMaxElapsedTime()

      Return the maximum elapsed time in milliseconds after which a call to `BackOffExecution.nextBackOff()` returns `BackOffExecution.STOP`.

    - #### start

          public BackOffExecution start()

      从接口复制的说明: `BackOff`
      Start a new back off execution.
      指定者:
        `start` 在接口中 `BackOff`
      返回:
        a fresh `BackOffExecution` ready to be used