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
The timed poll algorithm which uses jittered exponential backoff factor for calculating the next
poll execution time and throws
PollException in case if total timeout or total number of
attempts is reached.
This class is thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionExponentialPollAlgorithm(RetrySettings globalSettings, ApiClock clock) Creates a new exponential poll algorithm instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanshouldRetry(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, shouldRPCTerminate
-
Constructor Details
-
ExponentialPollAlgorithm
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 Details
-
shouldRetry
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
-