Class ExponentialBackOff.Builder
- java.lang.Object
-
- com.google.api.client.util.ExponentialBackOff.Builder
-
- Enclosing class:
- ExponentialBackOff
public static class ExponentialBackOff.Builder extends java.lang.Object
Builder forExponentialBackOff
.Implementation is not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
initialIntervalMillis
The initial retry interval in milliseconds.(package private) int
maxElapsedTimeMillis
The maximum elapsed time in milliseconds after instantiatingExponentialBackOff
or callingExponentialBackOff.reset()
after whichExponentialBackOff.nextBackOffMillis()
returnsBackOff.STOP
.(package private) int
maxIntervalMillis
The maximum value of the back off period in milliseconds.(package private) double
multiplier
The value to multiply the current interval with for each retry attempt.(package private) NanoClock
nanoClock
Nano clock.(package private) double
randomizationFactor
The randomization factor to use for creating a range around the retry interval.
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExponentialBackOff
build()
Builds a new instance ofExponentialBackOff
.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.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(NanoClock nanoClock)
Sets the nano clock (NanoClock.SYSTEM
by default).ExponentialBackOff.Builder
setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval.
-
-
-
Field Detail
-
initialIntervalMillis
int initialIntervalMillis
The initial retry interval in milliseconds.
-
randomizationFactor
double randomizationFactor
The randomization factor to use for creating a range around the retry interval.A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.
-
multiplier
double multiplier
The value to multiply the current interval with for each retry attempt.
-
maxIntervalMillis
int maxIntervalMillis
The maximum value of the back off period in milliseconds. Once the retry interval reaches this value it stops increasing.
-
maxElapsedTimeMillis
int maxElapsedTimeMillis
The maximum elapsed time in milliseconds after instantiatingExponentialBackOff
or callingExponentialBackOff.reset()
after whichExponentialBackOff.nextBackOffMillis()
returnsBackOff.STOP
.
-
nanoClock
NanoClock nanoClock
Nano clock.
-
-
Method Detail
-
build
public ExponentialBackOff build()
Builds a new instance ofExponentialBackOff
.
-
getInitialIntervalMillis
public final int getInitialIntervalMillis()
Returns the initial retry interval in milliseconds. The default value isExponentialBackOff.DEFAULT_INITIAL_INTERVAL_MILLIS
.
-
setInitialIntervalMillis
public ExponentialBackOff.Builder setInitialIntervalMillis(int initialIntervalMillis)
Sets the initial retry interval in milliseconds. The default value isExponentialBackOff.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.
-
getRandomizationFactor
public final double getRandomizationFactor()
Returns the randomization factor to use for creating a range around the retry interval. The default value isExponentialBackOff.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.
-
setRandomizationFactor
public ExponentialBackOff.Builder setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval. The default value isExponentialBackOff.DEFAULT_RANDOMIZATION_FACTOR
. Must fall in the range0 <= 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.
-
getMultiplier
public final double getMultiplier()
Returns the value to multiply the current interval with for each retry attempt. The default value isExponentialBackOff.DEFAULT_MULTIPLIER
.
-
setMultiplier
public ExponentialBackOff.Builder setMultiplier(double multiplier)
Sets the value to multiply the current interval with for each retry attempt. The default value isExponentialBackOff.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.
-
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 isExponentialBackOff.DEFAULT_MAX_INTERVAL_MILLIS
. Must be>= initialInterval
.
-
setMaxIntervalMillis
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 isExponentialBackOff.DEFAULT_MAX_INTERVAL_MILLIS
.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
getMaxElapsedTimeMillis
public final int getMaxElapsedTimeMillis()
Returns the maximum elapsed time in milliseconds. The default value isExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS
.If the time elapsed since an
ExponentialBackOff
instance is created goes past the max_elapsed_time then the methodExponentialBackOff.nextBackOffMillis()
starts returningBackOff.STOP
. The elapsed time can be reset by callingExponentialBackOff.reset()
.
-
setMaxElapsedTimeMillis
public ExponentialBackOff.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
Sets the maximum elapsed time in milliseconds. The default value isExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS
. Must be> 0
.If the time elapsed since an
ExponentialBackOff
instance is created goes past the max_elapsed_time then the methodExponentialBackOff.nextBackOffMillis()
starts returningBackOff.STOP
. The elapsed time can be reset by callingExponentialBackOff.reset()
.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
getNanoClock
public final NanoClock getNanoClock()
Returns the nano clock.
-
setNanoClock
public ExponentialBackOff.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.
-
-