Package com.google.api.gax.retrying
Class ExponentialPollAlgorithm
- java.lang.Object
-
- com.google.api.gax.retrying.ExponentialRetryAlgorithm
-
- com.google.api.gax.retrying.ExponentialPollAlgorithm
-
- All Implemented Interfaces:
TimedRetryAlgorithm
,TimedRetryAlgorithmWithContext
public class ExponentialPollAlgorithm extends ExponentialRetryAlgorithm
The timed poll algorithm which uses jittered exponential backoff factor for calculating the next poll execution time and throwsPollException
in case if total timeout or total number of attempts is reached.This class is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description ExponentialPollAlgorithm(RetrySettings globalSettings, com.google.api.core.ApiClock clock)
Creates a new exponential poll algorithm instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
shouldRetry(TimedAttemptSettings nextAttemptSettings)
Returnstrue
if another poll operation should be made or throwsPollException
, if either total timeout or total number of attempts is exceeded.-
Methods inherited from class com.google.api.gax.retrying.ExponentialRetryAlgorithm
createFirstAttempt, createFirstAttempt, createNextAttempt, createNextAttempt, nextRandomLong, shouldRetry
-
-
-
-
Constructor Detail
-
ExponentialPollAlgorithm
public ExponentialPollAlgorithm(RetrySettings globalSettings, com.google.api.core.ApiClock clock)
Creates a new exponential poll algorithm instance.- Parameters:
globalSettings
- global poll settings (attempt independent)clock
- clock to use for time-specific calculations- Throws:
NullPointerException
- if eitherglobalSettings
orclock
is null
-
-
Method Detail
-
shouldRetry
public boolean shouldRetry(TimedAttemptSettings nextAttemptSettings) throws PollException
Returnstrue
if another poll operation should be made or throwsPollException
, if either total timeout or total number of attempts is exceeded.- Specified by:
shouldRetry
in interfaceTimedRetryAlgorithm
- Overrides:
shouldRetry
in classExponentialRetryAlgorithm
- Parameters:
nextAttemptSettings
- attempt settings, which will be used for the next attempt, if accepted- Returns:
true
if more attempts should be made, never returnsfalse
(throwsPollException
instead)- Throws:
PollException
- if no more attempts should be made
-
-