@BetaApi public class ExponentialRetryAlgorithm extends Object implements TimedRetryAlgorithm
This class is thread-safe.
| Constructor and Description |
|---|
ExponentialRetryAlgorithm(RetrySettings globalSettings,
com.google.api.core.ApiClock clock)
Creates a new exponential retry algorithm instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(TimedAttemptSettings nextAttemptSettings)
Returns
true if another attempt should be made, or false otherwise. |
TimedAttemptSettings |
createFirstAttempt()
Creates a first attempt
TimedAttemptSettings. |
TimedAttemptSettings |
createNextAttempt(TimedAttemptSettings prevSettings)
Creates a next attempt
TimedAttemptSettings. |
public ExponentialRetryAlgorithm(RetrySettings globalSettings, com.google.api.core.ApiClock clock)
globalSettings - global retry settings (attempt independent)clock - clock to use for time-specific calculationsNullPointerException - if either globalSettings or clock is nullpublic TimedAttemptSettings createFirstAttempt()
TimedAttemptSettings. The first attempt is configured to be
executed immediately.createFirstAttempt in interface TimedRetryAlgorithmpublic TimedAttemptSettings createNextAttempt(TimedAttemptSettings prevSettings)
TimedAttemptSettings. The implementation increments the current
attempt count and uses randomized exponential backoff factor for calculating next attempt
execution time.createNextAttempt in interface TimedRetryAlgorithmprevSettings - previous attempt settingspublic boolean accept(TimedAttemptSettings nextAttemptSettings)
true if another attempt should be made, or false otherwise.accept in interface TimedRetryAlgorithmnextAttemptSettings - attempt settings, which will be used for the next attempt, if
acceptedtrue if nextAttemptSettings does not exceed either maxAttempts limit or
totalTimeout limit, or false otherwise