Package org.apache.bookkeeper.zookeeper
Class ExponentialBackOffWithDeadlinePolicy
java.lang.Object
org.apache.bookkeeper.zookeeper.ExponentialBackOffWithDeadlinePolicy
- All Implemented Interfaces:
RetryPolicy
Backoff time determined based as a multiple of baseBackoffTime.
The multiple value depends on retryCount.
If the retry schedule exceeds the deadline, we schedule a final attempt exactly at the deadline.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int(package private) static final int[] -
Constructor Summary
ConstructorsConstructorDescriptionExponentialBackOffWithDeadlinePolicy(long baseBackoffTime, long deadline, int maxRetries) -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowRetry(int retryCount, long elapsedRetryTime) Called when retrying an operation failed for some reason.longnextRetryWaitTime(int retryCount, long elapsedRetryTime) Called before making an attempt to retry a failed operation.
-
Field Details
-
RETRY_BACKOFF
static final int[] RETRY_BACKOFF -
JITTER_PERCENT
public static final int JITTER_PERCENT- See Also:
-
-
Constructor Details
-
ExponentialBackOffWithDeadlinePolicy
public ExponentialBackOffWithDeadlinePolicy(long baseBackoffTime, long deadline, int maxRetries)
-
-
Method Details
-
allowRetry
public boolean allowRetry(int retryCount, long elapsedRetryTime) Description copied from interface:RetryPolicyCalled when retrying an operation failed for some reason. Return true if another attempt is allowed to make.- Specified by:
allowRetryin interfaceRetryPolicy- Parameters:
retryCount- The number of times retried so far (1 for the first time).elapsedRetryTime- The elapsed time since the operation attempted. (in milliseconds)- Returns:
- true if anther attempt is allowed to make. otherwise, false.
-
nextRetryWaitTime
public long nextRetryWaitTime(int retryCount, long elapsedRetryTime) Description copied from interface:RetryPolicyCalled before making an attempt to retry a failed operation. Return 0 if an attempt needs to be made immediately.- Specified by:
nextRetryWaitTimein interfaceRetryPolicy- Parameters:
retryCount- The number of times retried so far (0 for the first time).elapsedRetryTime- The elapsed time since the operation attempted. (in milliseconds)- Returns:
- the elapsed time that the attempt needs to wait before retrying. (in milliseconds)
-