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 throws PollException in case if total timeout or total number of attempts is reached.

This class is thread-safe.

  • Constructor Details

    • 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 either globalSettings or clock is null
  • Method Details

    • shouldRetry

      public boolean shouldRetry(TimedAttemptSettings nextAttemptSettings) throws PollException
      Returns true if another poll operation should be made or throws PollException, if either total timeout or total number of attempts is exceeded.
      Specified by:
      shouldRetry in interface TimedRetryAlgorithm
      Overrides:
      shouldRetry in class ExponentialRetryAlgorithm
      Parameters:
      nextAttemptSettings - attempt settings, which will be used for the next attempt, if accepted
      Returns:
      true if more attempts should be made, never returns false (throws PollException instead)
      Throws:
      PollException - if no more attempts should be made