Class RandomExponentialRetry

java.lang.Object
org.apache.pulsar.io.elasticsearch.RandomExponentialRetry

public class RandomExponentialRetry extends Object
Implements the jitter backoff retry. see https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
  • Field Details

    • INSTANCE

      public static final RandomExponentialRetry INSTANCE
      Singleton instance.
    • maxRetryTimeInSec

      public final long maxRetryTimeInSec
      Maximum time in seconds between two retries.
  • Constructor Details

    • RandomExponentialRetry

      public RandomExponentialRetry()
    • RandomExponentialRetry

      public RandomExponentialRetry(long maxRetryTimeInSec)
  • Method Details

    • waitInMs

      public long waitInMs(int attempt, long backoffInMs)
    • randomWaitInMs

      public long randomWaitInMs(int attempt, long backoffInMs)
    • retry

      public <T> T retry(Callable<T> function, int maxAttempts, long initialBackoff, String source) throws Exception
      Throws:
      Exception
    • retry

      protected <T> T retry(Callable<T> function, int maxAttempts, long initialBackoff, String source, RandomExponentialRetry.Time clock) throws Exception
      Throws:
      Exception