public abstract class AbstractBackOffStrategy extends Object implements BackOffStrategy
BackOffStrategy| Constructor and Description |
|---|
AbstractBackOffStrategy(long baseBackOffTime)
A BackOffStrategy that can effectively be used endlessly.
|
AbstractBackOffStrategy(long baseBackOffTime,
int maximumNumberOfBackOffAttempts)
A BackOffStrategy that has a limited number of uses before it throws a
BackOffException. |
| Modifier and Type | Method and Description |
|---|---|
void |
backOff()
Cause the current thread to sleep for an amount of time based on the implemented strategy.
|
protected abstract long |
calculateBackOffTime(int attemptCount,
long baseSleepTime)
Calculate the amount of time in milliseconds that the strategy should back off for
|
void |
reset()
Rests the back off strategy to its original state.
|
public AbstractBackOffStrategy(long baseBackOffTime)
baseBackOffTime - amount of time back of in secondspublic AbstractBackOffStrategy(long baseBackOffTime,
int maximumNumberOfBackOffAttempts)
BackOffException.baseBackOffTime - time to back off in milliseconds, must be greater than 0.maximumNumberOfBackOffAttempts - maximum number of attempts, must be grater than 0 or -1.
-1 indicates there is no maximum number of attempts.public void backOff()
throws BackOffException
BackOffStrategybackOff in interface BackOffStrategyBackOffException - BackOffExceptionpublic void reset()
BackOffStrategybackOff()
has never been called.reset in interface BackOffStrategyprotected abstract long calculateBackOffTime(int attemptCount,
long baseSleepTime)
attemptCount - the number of attempts the strategy has backed off.
i.e. 1 -> this is the first attempt, 2 -> this is the second attempt, etc.baseSleepTime - the minimum amount of time it should back off for in millisecondsCopyright © 2020 The Apache Software Foundation. All rights reserved.