public final class DefaultBackoffPolicy extends Object implements BackoffPolicy
BackoffPolicy
that does an 'exponential' backoff. So each next attempt, the calculated delay is increased
and randomized (so the next value can be smaller than the previous, but overall they will increase).Modifier and Type | Field and Description |
---|---|
static BackoffPolicy |
MAX_100_MS |
Constructor and Description |
---|
DefaultBackoffPolicy()
Creates an ExponentialBackoffPolicy with 100 nanoseconds as minimal delay and 100 milliseconds as maximum
delay.
|
DefaultBackoffPolicy(long minDelayNs)
Creates an ExponentialBackoffPolicy with given maximum delay.
|
Modifier and Type | Method and Description |
---|---|
protected long |
calcDelayNs(int attempt) |
void |
delay(int attempt)
Delays the calling Thread.
|
void |
delayUninterruptible(int attempt)
Delays the calling Thread without being interrupted.
|
public static final BackoffPolicy MAX_100_MS
public DefaultBackoffPolicy()
public DefaultBackoffPolicy(long minDelayNs)
minDelayNs
- the minimum delay in nanoseconds to wait. If a negative or zero value provided, it will be
interpreted that no external minimal value is needed.NullPointerException
- if unit is null.public void delay(int attempt) throws InterruptedException
BackoffPolicy
The implementation is free to make this a no-op call.
delay
in interface BackoffPolicy
InterruptedException
public void delayUninterruptible(int attempt)
BackoffPolicy
The implementation is free to make this a no-op call.
delayUninterruptible
in interface BackoffPolicy
attempt
- theprotected long calcDelayNs(int attempt)
Copyright © 2020. All rights reserved.