E
- The type parameter of the Exception
instance signifying
terminal failure of the RetryPolicy
execution.public abstract class ExponentialBackoffRetryPolicy<E extends Exception> extends RetryPolicy<E>
RetryPolicy
that defines a maximum number of retries, and a delay
for retry attempts that increases exponentially based on a backoff factor.Constructor and Description |
---|
ExponentialBackoffRetryPolicy(int maxRetries,
int delayMs,
double backoffFactor,
int maxDelayMs,
boolean noDelayOnFirstRetry,
double jitter)
Creates a new
ExponentialBackoffRetryPolicy with the specified
maximum number of retries, and a delay for retry attempts that increases
exponentially based on a backoff factor. |
Modifier and Type | Method and Description |
---|---|
protected long |
getDelayMs(int attemptNo)
Returns the delay in milliseconds for the specified attempt number.
|
getMaxRetries, onRetry, onRetryFailure, retryOn, run, run
public ExponentialBackoffRetryPolicy(int maxRetries, int delayMs, double backoffFactor, int maxDelayMs, boolean noDelayOnFirstRetry, double jitter)
ExponentialBackoffRetryPolicy
with the specified
maximum number of retries, and a delay for retry attempts that increases
exponentially based on a backoff factor.maxRetries
- A positive value representing the number of retry
attempts allowed by the ExponentialBackoffRetryPolicy
.delayMs
- A positive value representing the delay for the first retry,
in milliseconds, which is also used as the multiplicative factor
for subsequent backed-off delays.backoffFactor
- The base of the backoff exponential function, i.e. a
value of 2
represents a backoff function of 2^a
,
where a
is the attempt number.maxDelayMs
- The maximum delay, in milliseconds, which takes effect if
the delay computed by the backoff function is a greater value.noDelayOnFirstRetry
- true
for the first retry to be attempted
immediately, otherwise false
for the first retry to be
attempted after delayMs
.jitter
- The factor multiplier to be applied to delayMs
to
thereafter be added to the delay for each retry.IllegalArgumentException
- If delayMs
, maxDelayMs
,
maxRetries
or jitter
is negative.protected long getDelayMs(int attemptNo)
RetryPolicy
getDelayMs
in class RetryPolicy<E extends Exception>
attemptNo
- The attempt number, starting with 1
.Copyright © 2020 LibJ. All rights reserved.