Package com.cloudera.cdp.http
Class ExponentialBackoffDelayPolicy
java.lang.Object
com.cloudera.cdp.http.ExponentialBackoffDelayPolicy
- All Implemented Interfaces:
DelayPolicy
Implement an exponential backoff policy. For a given 'base' and 'growthFactor'
a delay will be computed to be:
'base' * 'growthFactor' ^ (attempts - 1)
For example:
- base = 500ms, growthFactor = 2
- attempts = 1, delay = 500 * 2^0 = 500ms
- attempts = 2, delay = 500 * 2^1 = 1sec
- attempts = 3, delay = 500 * 2^2 = 2sec
- base = 500ms, growthFactor = 2, jitterPercentage = 5
- attempts = 1, delay = 500 * 2^0 +/- 25ms = 475ms - 525ms
- attempts = 2, delay = 500 * 2^1 +/- 50ms = 900ms - 1100ms
- attempts = 3, delay = 500 * 2^2 +/- 100ms= 1.9sec - 2.1sec
-
Constructor Summary
ConstructorDescriptionExponentialBackoffDelayPolicy
(int growthFactor, Duration base) Constructs an exponential backoff delay policy with the given 'growthFactor' and 'base'.ExponentialBackoffDelayPolicy
(int growthFactor, Duration base, int jitterPercentage) Constructs an exponential backoff delay policy with the given 'growthFactor', 'base', and 'jitterPercentage'. -
Method Summary
-
Constructor Details
-
ExponentialBackoffDelayPolicy
Constructs an exponential backoff delay policy with the given 'growthFactor' and 'base'. There is no jitter applied.- Parameters:
growthFactor
- The growth factor between delays. Must be positivebase
- The base. Must be a positive duration.
-
ExponentialBackoffDelayPolicy
Constructs an exponential backoff delay policy with the given 'growthFactor', 'base', and 'jitterPercentage'.- Parameters:
growthFactor
- The growth factor between delays. Must be positivebase
- The base. Must be a positive duration.jitterPercentage
- Percentage of jitter range applied to delay. Must non-negative.
-
-
Method Details
-
delay
Description copied from interface:DelayPolicy
Returns the delay needed before attempting the next retry.- Specified by:
delay
in interfaceDelayPolicy
- Parameters:
attempts
- The number of attempts made to make the call- Returns:
- The duration to wait
-