Class RandomExponentialRetry
java.lang.Object
org.apache.pulsar.io.elasticsearch.RandomExponentialRetry
Implements the jitter backoff retry.
see https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RandomExponentialRetry
Singleton instance.final long
Maximum time in seconds between two retries. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
randomWaitInMs
(int attempt, long backoffInMs) <T> T
protected <T> T
retry
(Callable<T> function, int maxAttempts, long initialBackoff, String source, RandomExponentialRetry.Time clock) long
waitInMs
(int attempt, long backoffInMs)
-
Field Details
-
INSTANCE
Singleton instance. -
maxRetryTimeInSec
public final long maxRetryTimeInSecMaximum 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
-