public static class ExponentialBackOff.Builder
extends java.lang.Object
Builder for ExponentialBackOff.
<p> Implementation is not thread-safe. </p>
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
ExponentialBackOff |
build()
Builds a new instance of
ExponentialBackOff. |
int |
getInitialIntervalMillis()
Returns the initial retry interval in milliseconds.
|
int |
getMaxElapsedTimeMillis()
Returns the maximum elapsed time in milliseconds.
|
int |
getMaxIntervalMillis()
Returns the maximum value of the back off period in milliseconds.
|
double |
getMultiplier()
Returns the value to multiply the current interval with for each retry attempt.
|
ExponentialBackOff.NanoClock |
getNanoClock()
Returns the nano clock.
|
double |
getRandomizationFactor()
Returns the randomization factor to use for creating a range around the retry interval.
|
ExponentialBackOff.Builder |
setInitialIntervalMillis(int initialIntervalMillis)
Sets the initial retry interval in milliseconds.
|
ExponentialBackOff.Builder |
setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
Sets the maximum elapsed time in milliseconds.
|
ExponentialBackOff.Builder |
setMaxIntervalMillis(int maxIntervalMillis)
Sets the maximum value of the back off period in milliseconds.
|
ExponentialBackOff.Builder |
setMultiplier(double multiplier)
Sets the value to multiply the current interval with for each retry attempt.
|
ExponentialBackOff.Builder |
setNanoClock(ExponentialBackOff.NanoClock nanoClock)
Sets the nano clock (
ExponentialBackOff.NanoClock.SYSTEM by default). |
ExponentialBackOff.Builder |
setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval.
|
public ExponentialBackOff build()
Builds a new instance of ExponentialBackOff.
public final int getInitialIntervalMillis()
Returns the initial retry interval in milliseconds. The default value is
ExponentialBackOff.DEFAULT_INITIAL_INTERVAL_MILLIS.
public ExponentialBackOff.Builder setInitialIntervalMillis(int initialIntervalMillis)
Sets the initial retry interval in milliseconds. The default value is
ExponentialBackOff.DEFAULT_INITIAL_INTERVAL_MILLIS. Must be > 0.
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
public final double getRandomizationFactor()
Returns the randomization factor to use for creating a range around the retry interval. The
default value is ExponentialBackOff.DEFAULT_RANDOMIZATION_FACTOR.
<p> A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval. </p>
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
public ExponentialBackOff.Builder setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval. The
default value is ExponentialBackOff.DEFAULT_RANDOMIZATION_FACTOR. Must fall in the range
0 ⇐ randomizationFactor < 1.
<p> A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval. </p>
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
public final double getMultiplier()
Returns the value to multiply the current interval with for each retry attempt. The default
value is ExponentialBackOff.DEFAULT_MULTIPLIER.
public ExponentialBackOff.Builder setMultiplier(double multiplier)
Sets the value to multiply the current interval with for each retry attempt. The default
value is ExponentialBackOff.DEFAULT_MULTIPLIER. Must be >= 1.
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
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
ExponentialBackOff.DEFAULT_MAX_INTERVAL_MILLIS. Must be >= initialInterval.
public ExponentialBackOff.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
ExponentialBackOff.DEFAULT_MAX_INTERVAL_MILLIS.
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
public final int getMaxElapsedTimeMillis()
Returns the maximum elapsed time in milliseconds. The default value is
ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS.
<p>
If the time elapsed since an ExponentialBackOff instance is created goes past the
max_elapsed_time then the method ExponentialBackOff.nextBackOffMillis() starts returning
BackOff.STOP. The elapsed time can be reset by calling ExponentialBackOff.reset().
</p>
public ExponentialBackOff.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
Sets the maximum elapsed time in milliseconds. The default value is
ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS. Must be > 0.
<p>
If the time elapsed since an ExponentialBackOff instance is created goes past the
max_elapsed_time then the method ExponentialBackOff.nextBackOffMillis() starts returning
BackOff.STOP. The elapsed time can be reset by calling ExponentialBackOff.reset().
</p>
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>
public final ExponentialBackOff.NanoClock getNanoClock()
Returns the nano clock.
public ExponentialBackOff.Builder setNanoClock(ExponentialBackOff.NanoClock nanoClock)
Sets the nano clock (ExponentialBackOff.NanoClock.SYSTEM by default).
<p> Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else. </p>