public class ConstantTimeBackOffStrategy extends AbstractBackOffStrategy
AbstractBackOffStrategy
that causes the current thread to sleep the
same amount of time each time backOff()
is called.Constructor and Description |
---|
ConstantTimeBackOffStrategy(long baseBackOffTimeInMiliseconds)
A ConstantTimeBackOffStrategy that can effectively be used endlessly.
|
ConstantTimeBackOffStrategy(long baseBackOffTimeInMiliseconds,
int maximumNumberOfBackOffAttempts)
A ConstantTimeBackOffStrategy that has a limited number of uses before it throws a
BackOffException |
Modifier and Type | Method and Description |
---|---|
protected long |
calculateBackOffTime(int attemptCount,
long baseSleepTime)
Calculate the amount of time in milliseconds that the strategy should back off for
|
backOff, reset
public ConstantTimeBackOffStrategy(long baseBackOffTimeInMiliseconds)
baseBackOffTimeInMiliseconds
- amount of time back of in millisecondspublic ConstantTimeBackOffStrategy(long baseBackOffTimeInMiliseconds, int maximumNumberOfBackOffAttempts)
BackOffException
baseBackOffTimeInMiliseconds
- 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.protected long calculateBackOffTime(int attemptCount, long baseSleepTime)
AbstractBackOffStrategy
calculateBackOffTime
in class AbstractBackOffStrategy
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 © 2012–2016 The Apache Software Foundation. All rights reserved.