org.springframework.retry.backoff
Class ExponentialRandomBackOffPolicy
java.lang.Object
org.springframework.retry.backoff.ExponentialBackOffPolicy
org.springframework.retry.backoff.ExponentialRandomBackOffPolicy
- All Implemented Interfaces:
- BackOffPolicy, SleepingBackOffPolicy<ExponentialBackOffPolicy>
public class ExponentialRandomBackOffPolicy
- extends ExponentialBackOffPolicy
Implementation of ExponentialBackOffPolicy
that
chooses a random multiple of the interval. The random multiple is selected based on
how many iterations have occurred.
This has shown to at least be useful in testing scenarios where excessive contention is generated
by the test needing many retries. In test, usually threads are started at the same time, and thus
stomp together onto the next interval. Using this BackOffPolicy
can help avoid that scenario.
Example:
initialInterval = 50
multiplier = 2.0
maxInterval = 3000
numRetries = 5
ExponentialBackOffPolicy
yields: [50, 100, 200, 400, 800]
ExponentialRandomBackOffPolicy
may yield [50, 100, 100, 100, 600]
or [50, 100, 150, 400, 800]
- Author:
- Jon Travis, Dave Syer
Methods inherited from class org.springframework.retry.backoff.ExponentialBackOffPolicy |
backOff, cloneValues, getInitialInterval, getMaxInterval, getMultiplier, setInitialInterval, setMaxInterval, setMultiplier, setSleeper, toString, withSleeper |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ExponentialRandomBackOffPolicy
public ExponentialRandomBackOffPolicy()
start
public BackOffContext start(RetryContext context)
- Returns a new instance of
BackOffContext
, seeded with this
policies settings.
- Specified by:
start
in interface BackOffPolicy
- Overrides:
start
in class ExponentialBackOffPolicy
- Parameters:
context
- the current retry context, which might contain information
that we can use to decide how to proceed.
- Returns:
- the implementation-specific
BackOffContext
or 'null
'.
newInstance
protected ExponentialBackOffPolicy newInstance()
- Overrides:
newInstance
in class ExponentialBackOffPolicy
Copyright © 2013 SpringSource. All Rights Reserved.