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 throwsPollExceptionin case if total timeout or total number of attempts is reached.This class is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description ExponentialPollAlgorithm(RetrySettings globalSettings, ApiClock clock)Creates a new exponential poll algorithm instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanshouldRetry(TimedAttemptSettings nextAttemptSettings)Returnstrueif 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, 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 eitherglobalSettingsorclockis null
-
-
Method Detail
-
shouldRetry
public boolean shouldRetry(TimedAttemptSettings nextAttemptSettings) throws PollException
Returnstrueif another poll operation should be made or throwsPollException, if either total timeout or total number of attempts is exceeded.- Specified by:
shouldRetryin interfaceTimedRetryAlgorithm- Overrides:
shouldRetryin classExponentialRetryAlgorithm- Parameters:
nextAttemptSettings- attempt settings, which will be used for the next attempt, if accepted- Returns:
trueif more attempts should be made, never returnsfalse(throwsPollExceptioninstead)- Throws:
PollException- if no more attempts should be made
-
-