Class Backoff
java.lang.Object
org.apache.bookkeeper.common.util.Backoff
Implements various backoff strategies.
Strategies are defined by a Stream of durations
and are intended to determine the duration after which a task is to be
retried.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA constant backoff policy.static classA exponential backoff policy.static classA Jittered backoff policy.static interfaceBack off policy. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconstant(long startMs) Create a stream with constant backoffs.decorrelatedJittered(long startMs, long maxMs) Create an infinite backoffs that have jitter with a random distribution betweenstartMsand 3 times the previously selected value, capped atmaxMs.equalJittered(long startMs, long maxMs) Create infinite backoffs that keep half of the exponential growth, and jitter between 0 and that amount.exponential(long startMs, int multiplier, long maxMs) Create a stream with exponential backoffs.exponentialJittered(long startMs, long maxMs) Create a stream of exponential backoffs with jitters.
-
Field Details
-
DEFAULT
-
-
Constructor Details
-
Backoff
public Backoff()
-
-
Method Details
-
constant
Create a stream with constant backoffs.- Parameters:
startMs- initial backoff in milliseconds- Returns:
- a stream with constant backoff values.
-
exponential
Create a stream with exponential backoffs.- Parameters:
startMs- initial backoff in milliseconds.multiplier- the multiplier for next backoff.maxMs- max backoff in milliseconds.- Returns:
- a stream with exponential backoffs.
-
exponentialJittered
Create a stream of exponential backoffs with jitters.This is "full jitter" via http://www.awsarchitectureblog.com/2015/03/backoff.html
- Parameters:
startMs- initial backoff in milliseconds.maxMs- max backoff in milliseconds.- Returns:
- a stream of exponential backoffs with jitters.
-
equalJittered
Create infinite backoffs that keep half of the exponential growth, and jitter between 0 and that amount.this is "equal jitter" via http://www.awsarchitectureblog.com/2015/03/backoff.html
- Parameters:
startMs- initial backoff in milliseconds.maxMs- max backoff in milliseconds.- Returns:
- a stream of exponential backoffs with jitters.
-