public static class ExponentialBackOffPolicy.Builder extends Object
ExponentialBackOffPolicy
.
Implementation is not thread-safe.
Modifier | Constructor and Description |
---|---|
protected |
ExponentialBackOffPolicy.Builder() |
Modifier and Type | Method and Description |
---|---|
ExponentialBackOffPolicy |
build()
Builds a new instance of
ExponentialBackOffPolicy . |
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.
|
double |
getRandomizationFactor()
Returns the randomization factor to use for creating a range around the retry interval.
|
ExponentialBackOffPolicy.Builder |
setInitialIntervalMillis(int initialIntervalMillis)
Sets the initial retry interval in milliseconds.
|
ExponentialBackOffPolicy.Builder |
setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
Sets the maximum elapsed time in milliseconds.
|
ExponentialBackOffPolicy.Builder |
setMaxIntervalMillis(int maxIntervalMillis)
Sets the maximum value of the back off period in milliseconds.
|
ExponentialBackOffPolicy.Builder |
setMultiplier(double multiplier)
Sets the value to multiply the current interval with for each retry attempt.
|
ExponentialBackOffPolicy.Builder |
setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval.
|
public ExponentialBackOffPolicy build()
ExponentialBackOffPolicy
.public final int getInitialIntervalMillis()
ExponentialBackOffPolicy.DEFAULT_INITIAL_INTERVAL_MILLIS
.public ExponentialBackOffPolicy.Builder setInitialIntervalMillis(int initialIntervalMillis)
ExponentialBackOffPolicy.DEFAULT_INITIAL_INTERVAL_MILLIS
. Must be > 0
.public final double getRandomizationFactor()
ExponentialBackOffPolicy.DEFAULT_RANDOMIZATION_FACTOR
.
A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.
public ExponentialBackOffPolicy.Builder setRandomizationFactor(double randomizationFactor)
ExponentialBackOffPolicy.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.
public final double getMultiplier()
ExponentialBackOffPolicy.DEFAULT_MULTIPLIER
.public ExponentialBackOffPolicy.Builder setMultiplier(double multiplier)
ExponentialBackOffPolicy.DEFAULT_MULTIPLIER
. Must be >= 1
.public final int getMaxIntervalMillis()
ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL_MILLIS
. Must be >= initialInterval
.public ExponentialBackOffPolicy.Builder setMaxIntervalMillis(int maxIntervalMillis)
ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL_MILLIS
.public final int getMaxElapsedTimeMillis()
ExponentialBackOffPolicy.DEFAULT_MAX_ELAPSED_TIME_MILLIS
.
If the time elapsed since an ExponentialBackOffPolicy
instance is created goes past
the max_elapsed_time then the method ExponentialBackOffPolicy.getNextBackOffMillis()
starts returning
BackOffPolicy.STOP
. The elapsed time can be reset by calling ExponentialBackOffPolicy.reset()
.
public ExponentialBackOffPolicy.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
ExponentialBackOffPolicy.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 ExponentialBackOffPolicy.getNextBackOffMillis()
starts returning
BackOffPolicy.STOP
. The elapsed time can be reset by calling ExponentialBackOffPolicy.reset()
.
Copyright © 2011-2012 Google. All Rights Reserved.