{@link #getNextBackOffMillis()} is calculated using the following formula:
randomized_interval = retry_interval * (random value in range [1 - randomization_factor, 1 + randomization_factor])In other words {@link #getNextBackOffMillis()} will range between the randomization factorpercentage below and above the retry interval. For example, using 2 seconds as the base retry interval and 0.5 as the randomization factor, the actual back off period used in the next retry attempt will be between 1 and 3 seconds.
Note: max_interval caps the retry_interval and not the randomized_interval.
If the time elapsed since an {@link ExponentialBackOffPolicy} instance is created goes past themax_elapsed_time then the method {@link #getNextBackOffMillis()} starts returning{@link BackOffPolicy#STOP}. The elapsed time can be reset by calling {@link #reset()}.
Example: The default retry_interval is .5 seconds, default randomization_factor is 0.5, default multiplier is 1.5 and the default max_interval is 1 minute. For 10 requests the sequence will be (values in seconds) and assuming we go over the max_elapsed_time on the 10th request:
request# retry_interval randomized_interval 1 0.5 [0.25, 0.75] 2 0.75 [0.375, 1.125] 3 1.125 [0.562, 1.687] 4 1.687 [0.8435, 2.53] 5 2.53 [1.265, 3.795] 6 3.795 [1.897, 5.692] 7 5.692 [2.846, 8.538] 8 8.538 [4.269, 12.807] 9 12.807 [6.403, 19.210] 10 19.210 {@link BackOffPolicy#STOP}
Implementation is not thread-safe.
@since 1.7 @author Ravi Mistry
|
|
|
|
|
|