Class ExponentialBackOffPolicy.Builder (1.43.2)

public static class ExponentialBackOffPolicy.Builder

Beta
Builder for ExponentialBackOffPolicy.

Implementation is not thread-safe.

Inheritance

java.lang.Object > ExponentialBackOffPolicy.Builder

Constructors

Builder()

protected Builder()

Methods

build()

public ExponentialBackOffPolicy build()

Builds a new instance of ExponentialBackOffPolicy.

Returns
Type Description
ExponentialBackOffPolicy

getInitialIntervalMillis()

public final int getInitialIntervalMillis()

Returns the initial retry interval in milliseconds. The default value is #DEFAULT_INITIAL_INTERVAL_MILLIS.

Returns
Type Description
int

getMaxElapsedTimeMillis()

public final int getMaxElapsedTimeMillis()

Returns the maximum elapsed time in milliseconds. The default value is #DEFAULT_MAX_ELAPSED_TIME_MILLIS.

If the time elapsed since an ExponentialBackOffPolicy instance is created goes past the max_elapsed_time then the method #getNextBackOffMillis() starts returning BackOffPolicy#STOP. The elapsed time can be reset by calling #reset().

Returns
Type Description
int

getMaxIntervalMillis()

public final int getMaxIntervalMillis()

Returns the maximum value of the back off period in milliseconds. Once the current interval reaches this value it stops increasing. The default value is #DEFAULT_MAX_INTERVAL_MILLIS. Must be >= initialInterval.

Returns
Type Description
int

getMultiplier()

public final double getMultiplier()

Returns the value to multiply the current interval with for each retry attempt. The default value is #DEFAULT_MULTIPLIER.

Returns
Type Description
double

getNanoClock()

public final NanoClock getNanoClock()

Returns the nano clock.

Returns
Type Description
NanoClock

getRandomizationFactor()

public final double getRandomizationFactor()

Returns the randomization factor to use for creating a range around the retry interval. The default value is #DEFAULT_RANDOMIZATION_FACTOR.

A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Returns
Type Description
double

setInitialIntervalMillis(int initialIntervalMillis)

public ExponentialBackOffPolicy.Builder setInitialIntervalMillis(int initialIntervalMillis)

Sets the initial retry interval in milliseconds. The default value is #DEFAULT_INITIAL_INTERVAL_MILLIS. Must be > 0.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
initialIntervalMillis int
Returns
Type Description
ExponentialBackOffPolicy.Builder

setMaxElapsedTimeMillis(int maxElapsedTimeMillis)

public ExponentialBackOffPolicy.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)

Sets the maximum elapsed time in milliseconds. The default value is #DEFAULT_MAX_ELAPSED_TIME_MILLIS. Must be > 0.

If the time elapsed since an ExponentialBackOffPolicy instance is created goes past the max_elapsed_time then the method #getNextBackOffMillis() starts returning BackOffPolicy#STOP. The elapsed time can be reset by calling #reset().

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
maxElapsedTimeMillis int
Returns
Type Description
ExponentialBackOffPolicy.Builder

setMaxIntervalMillis(int maxIntervalMillis)

public ExponentialBackOffPolicy.Builder setMaxIntervalMillis(int maxIntervalMillis)

Sets the maximum value of the back off period in milliseconds. Once the current interval reaches this value it stops increasing. The default value is #DEFAULT_MAX_INTERVAL_MILLIS.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
maxIntervalMillis int
Returns
Type Description
ExponentialBackOffPolicy.Builder

setMultiplier(double multiplier)

public ExponentialBackOffPolicy.Builder setMultiplier(double multiplier)

Sets the value to multiply the current interval with for each retry attempt. The default value is #DEFAULT_MULTIPLIER. Must be >= 1.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
multiplier double
Returns
Type Description
ExponentialBackOffPolicy.Builder

setNanoClock(NanoClock nanoClock)

public ExponentialBackOffPolicy.Builder setNanoClock(NanoClock nanoClock)

Sets the nano clock (NanoClock#SYSTEM by default).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
nanoClock NanoClock
Returns
Type Description
ExponentialBackOffPolicy.Builder

setRandomizationFactor(double randomizationFactor)

public ExponentialBackOffPolicy.Builder setRandomizationFactor(double randomizationFactor)

Sets the randomization factor to use for creating a range around the retry interval. The default value is #DEFAULT_RANDOMIZATION_FACTOR. Must fall in the range 0 <= randomizationFactor < 1.

A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
randomizationFactor double
Returns
Type Description
ExponentialBackOffPolicy.Builder