public class Backoff
extends java.lang.Object
Strategies are defined by a Stream of durations
and are intended to determine the duration after which a task is to be
retried.
| Modifier and Type | Class and Description |
|---|---|
static class |
Backoff.Constant
A constant backoff policy.
|
static class |
Backoff.Exponential
A exponential backoff policy.
|
static class |
Backoff.Jitter
A Jittered backoff policy.
|
static interface |
Backoff.Policy
Back off policy.
|
| Modifier and Type | Field and Description |
|---|---|
static Backoff.Policy |
DEFAULT |
| Constructor and Description |
|---|
Backoff() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.stream.Stream<java.lang.Long> |
constant(long startMs)
Create a stream with constant backoffs.
|
static java.util.stream.Stream<java.lang.Long> |
decorrelatedJittered(long startMs,
long maxMs)
Create an infinite backoffs that have jitter with a random distribution
between
startMs and 3 times the previously selected value, capped at maxMs. |
static java.util.stream.Stream<java.lang.Long> |
equalJittered(long startMs,
long maxMs)
Create infinite backoffs that keep half of the exponential growth, and jitter
between 0 and that amount.
|
static java.util.stream.Stream<java.lang.Long> |
exponential(long startMs,
int multiplier,
long maxMs)
Create a stream with exponential backoffs.
|
static java.util.stream.Stream<java.lang.Long> |
exponentialJittered(long startMs,
long maxMs)
Create a stream of exponential backoffs with jitters.
|
public static final Backoff.Policy DEFAULT
public static java.util.stream.Stream<java.lang.Long> constant(long startMs)
startMs - initial backoff in millisecondspublic static java.util.stream.Stream<java.lang.Long> exponential(long startMs,
int multiplier,
long maxMs)
startMs - initial backoff in milliseconds.multiplier - the multiplier for next backoff.maxMs - max backoff in milliseconds.public static java.util.stream.Stream<java.lang.Long> exponentialJittered(long startMs,
long maxMs)
This is "full jitter" via http://www.awsarchitectureblog.com/2015/03/backoff.html
startMs - initial backoff in milliseconds.maxMs - max backoff in milliseconds.public static java.util.stream.Stream<java.lang.Long> decorrelatedJittered(long startMs,
long maxMs)
startMs and 3 times the previously selected value, capped at maxMs.
this is "decorrelated jitter" via http://www.awsarchitectureblog.com/2015/03/backoff.html
startMs - initial backoff in millisecondsmaxMs - max backoff in millisecondspublic static java.util.stream.Stream<java.lang.Long> equalJittered(long startMs,
long maxMs)
this is "equal jitter" via http://www.awsarchitectureblog.com/2015/03/backoff.html
startMs - initial backoff in milliseconds.maxMs - max backoff in milliseconds.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.