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 2000 ms; the default multiplier is 1.5; and the default max interval is 30000. 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, and the
default maximum number of attempts is Integer#MAX_VALUE.
Use setMaxElapsedTime to limit the length of time that an instance
should accumulate before returning BackOffExecution#STOP. Alternatively,
use setMaxAttempts to limit the number of attempts. The execution
stops when either of those two limits is reached.
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| public static final long | DEFAULT_INITIAL_INTERVAL
The default initial interval. |
| public static final int | DEFAULT_MAX_ATTEMPTS
The default maximum attempts. |
| public static final long | DEFAULT_MAX_ELAPSED_TIME
The default maximum elapsed time. |
| public static final long | DEFAULT_MAX_INTERVAL
The default maximum back off time. |
| public static final double | DEFAULT_MULTIPLIER
The default multiplier (increases the interval by 50%). |
| private long | |
| private int | |
| private long | |
| private long | |
| private double |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ExponentialBackOff(long
the initial interval in milliseconds initialInterval, double the multiplier (should be greater than or equal to 1) multiplier)Create an instance with the supplied settings. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public long | |
| public int | Returns: the maximum number of attemptsReturn the maximum number of attempts after which a call to
|
| public long | Returns: the maximum elapsed timeReturn the maximum elapsed time in milliseconds after which a call to
|
| public long | |
| public double | |
| public void | |
| public void | setMaxAttempts(int
the maximum number of attempts maxAttempts)The maximum number of attempts after which a call to
|
| public void | setMaxElapsedTime(long
the maximum elapsed time maxElapsedTime)Set the maximum elapsed time in milliseconds after which a call to
|
| public void | |
| public void | setMultiplier(double multiplier)
Set the value to multiply the current interval by for each retry attempt. |
| public BackOffExecution | |
| public String |
| DEFAULT_INITIAL_INTERVAL | back to summary |
|---|---|
| public static final long DEFAULT_INITIAL_INTERVAL The default initial interval. | |
| DEFAULT_MAX_ATTEMPTS | back to summary |
|---|---|
| public static final int DEFAULT_MAX_ATTEMPTS The default maximum attempts.
| |
| DEFAULT_MAX_ELAPSED_TIME | back to summary |
|---|---|
| public static final long DEFAULT_MAX_ELAPSED_TIME The default maximum elapsed time. | |
| DEFAULT_MAX_INTERVAL | back to summary |
|---|---|
| public static final long DEFAULT_MAX_INTERVAL The default maximum back off time. | |
| DEFAULT_MULTIPLIER | back to summary |
|---|---|
| public static final double DEFAULT_MULTIPLIER The default multiplier (increases the interval by 50%). | |
| initialInterval | back to summary |
|---|---|
| private long initialInterval | |
| maxAttempts | back to summary |
|---|---|
| private int maxAttempts | |
| maxElapsedTime | back to summary |
|---|---|
| private long maxElapsedTime | |
| maxInterval | back to summary |
|---|---|
| private long maxInterval | |
| multiplier | back to summary |
|---|---|
| private double multiplier | |
| ExponentialBackOff | back to summary |
|---|---|
| public ExponentialBackOff() Create an instance with the default settings. | |
| ExponentialBackOff | back to summary |
|---|---|
| public ExponentialBackOff(long initialInterval, double multiplier) Create an instance with the supplied settings.
| |
| checkMultiplier | back to summary |
|---|---|
| private void checkMultiplier(double multiplier) | |
| getInitialInterval | back to summary |
|---|---|
| public long getInitialInterval() Return the initial interval in milliseconds. | |
| getMaxAttempts | back to summary |
|---|---|
| public int getMaxAttempts() Return the maximum number of attempts after which a call to
| |
| getMaxElapsedTime | back to summary |
|---|---|
| public long getMaxElapsedTime() Return the maximum elapsed time in milliseconds after which a call to
| |
| getMaxInterval | back to summary |
|---|---|
| public long getMaxInterval() Return the maximum back off time in milliseconds. | |
| getMultiplier | back to summary |
|---|---|
| public double getMultiplier() Return the value to multiply the current interval by for each retry attempt. | |
| setInitialInterval | back to summary |
|---|---|
| public void setInitialInterval(long initialInterval) Set the initial interval in milliseconds. | |
| setMaxAttempts | back to summary |
|---|---|
| public void setMaxAttempts(int maxAttempts) The maximum number of attempts after which a call to
| |
| setMaxElapsedTime | back to summary |
|---|---|
| public void setMaxElapsedTime(long maxElapsedTime) Set the maximum elapsed time in milliseconds after which a call to
| |
| setMaxInterval | back to summary |
|---|---|
| public void setMaxInterval(long maxInterval) Set the maximum back off time in milliseconds. | |
| setMultiplier | back to summary |
|---|---|
| public void setMultiplier(double multiplier) Set the value to multiply the current interval by for each retry attempt. | |
| start | back to summary |
|---|---|
| public BackOffExecution start() Implements org. Doc from org. Start a new back off execution.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private long | |
| private long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private long | |
| private long | |
| public long | nextBackOff()
Implements org. Return the number of milliseconds to wait before retrying the operation
or |
| public String |
| attempts | back to summary |
|---|---|
| private int attempts | |
| currentElapsedTime | back to summary |
|---|---|
| private long currentElapsedTime | |
| currentInterval | back to summary |
|---|---|
| private long currentInterval | |
| ExponentialBackOffExecution | back to summary |
|---|---|
| private ExponentialBackOffExecution() | |
| computeNextInterval | back to summary |
|---|---|
| private long computeNextInterval() | |
| multiplyInterval | back to summary |
|---|---|
| private long multiplyInterval(long maxInterval) | |
| nextBackOff | back to summary |
|---|---|
| public long nextBackOff() Implements org. Doc from org. Return the number of milliseconds to wait before retrying the operation
or
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |