|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.retry.backoff.ExponentialBackOffPolicy
public class ExponentialBackOffPolicy
Implementation of BackOffPolicy
that increases the back off period
for each retry attempt in a given set using the exponential
function.
setInitialInterval(long)
property controls the initial value
passed to Math.exp(double)
and the setMultiplier(double)
property controls by how much this value is increased for each subsequent
attempt.
Field Summary | |
---|---|
static long |
DEFAULT_INITIAL_INTERVAL
The default 'initialInterval' value - 100 millisecs. |
static long |
DEFAULT_MAX_INTERVAL
The default maximum backoff time (30 seconds). |
static double |
DEFAULT_MULTIPLIER
The default 'multiplier' value - value 2 (100% increase per backoff). |
Constructor Summary | |
---|---|
ExponentialBackOffPolicy()
|
Method Summary | |
---|---|
void |
backOff(BackOffContext backOffContext)
Pause for a length of time equal to ' exp(backOffContext.expSeed) '. |
long |
getInitialInterval()
The initial period to sleep on the first backoff. |
long |
getMaxInterval()
The maximum interval to sleep for. |
double |
getMultiplier()
The multiplier to use to generate the next backoff interval from the last. |
void |
setInitialInterval(long initialInterval)
Set the initial sleep interval value. |
void |
setMaxInterval(long maxInterval)
Setter for maximum back off period. |
void |
setMultiplier(double multiplier)
Set the multiplier value. |
void |
setSleeper(Sleeper sleeper)
Public setter for the Sleeper strategy. |
BackOffContext |
start(RetryContext context)
Returns a new instance of BackOffContext configured with the
'expSeed' and 'increment' values. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_INITIAL_INTERVAL
public static final long DEFAULT_MAX_INTERVAL
public static final double DEFAULT_MULTIPLIER
Constructor Detail |
---|
public ExponentialBackOffPolicy()
Method Detail |
---|
public void setSleeper(Sleeper sleeper)
Sleeper
strategy.
sleeper
- the sleeper to set defaults to ObjectWaitSleeper
.public void setInitialInterval(long initialInterval)
100
millisecond. Cannot be set to a value less than one.
public void setMultiplier(double multiplier)
2.0
'. Hint: do not use
values much in excess of 1.0 (or the backoff will get very long very
fast).
public void setMaxInterval(long maxInterval)
maxInterval
- in milliseconds.public long getInitialInterval()
public long getMaxInterval()
public double getMultiplier()
public BackOffContext start(RetryContext context)
BackOffContext
configured with the
'expSeed' and 'increment' values.
start
in interface BackOffPolicy
context
- the current retry context, which might contain information
that we can use to decide how to proceed.
BackOffContext
or 'null
'.public void backOff(BackOffContext backOffContext) throws BackOffInterruptedException
exp(backOffContext.expSeed)
'.
backOff
in interface BackOffPolicy
BackOffInterruptedException
- if the attempt at back off is
interrupted.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |