Package com.backblaze.b2.client
Interface B2RetryPolicy
-
- All Known Implementing Classes:
B2DefaultRetryPolicy
public interface B2RetryPolicy
The B2RetryPolicy is called once after each attempt. It is always passed the number of attempts that have been made so far (attemptsSoFar) and the number of milliseconds the call took (tookMs). For unsuccessful attempts, it is also passed the exception which caused the failure. For each of the getRetryable*() methods, the policy is consulted to decide whether (and when) to retry. By the way, attemptsSoFar starts at 1.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Integer
gotRetryableAfterDelay(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw a retryable B2Exception but we have to wait a while before retrying.boolean
gotRetryableImmediately(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw a retryable B2Exception.default void
gotUnexpectedUnretryable(java.lang.String operation, int attemptsSoFar, long tookMillis, java.lang.Exception e)
Callable.call() threw an Exception that wasn't a B2Exception.default void
gotUnretryable(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw an unretryable B2Exception.default void
succeeded(java.lang.String operation, int attemptsSoFar, long tookMillis)
Called when callable.call() returns without an exception.
-
-
-
Method Detail
-
succeeded
default void succeeded(java.lang.String operation, int attemptsSoFar, long tookMillis)
Called when callable.call() returns without an exception.- Parameters:
operation
- the name of what is being retried. *usually* the name of a b2 operation.attemptsSoFar
- how many times have we called callable.call() so far?tookMillis
- how long did this attempt take?
-
gotRetryableAfterDelay
java.lang.Integer gotRetryableAfterDelay(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw a retryable B2Exception but we have to wait a while before retrying. If the guide decides we've tried enough times, it should return null. Otherwise, it should return the number of seconds to sleep before trying again.if e.getRetryAfterSecondsOrNull() is not null, it's the number of seconds the server suggests that you wait before trying again.
WARNING: if we only hit retryable errors and this never returns null, we will keep retrying indefinitely. You have been warned.
- Parameters:
operation
- the name of what is being retried. *usually* the name of a b2 operation.attemptsSoFar
- how many times have we called callable.call() so far?tookMillis
- how long did this attempt take?e
- the retryable exception.- Returns:
- null to stop trying OR the number of seconds to sleep before trying again.
-
gotRetryableImmediately
boolean gotRetryableImmediately(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw a retryable B2Exception. We will retry immediately.- Parameters:
operation
- the name of what is being retried. *usually* the name of a b2 operation.attemptsSoFar
- how many times have we called callable.call() so far?tookMillis
- how long did this attempt take?e
- the retryable exception.- Returns:
- true iff we should try again.
-
gotUnretryable
default void gotUnretryable(java.lang.String operation, int attemptsSoFar, long tookMillis, B2Exception e)
Callable.call() threw an unretryable B2Exception. No more attempts will be made.- Parameters:
operation
- the name of what is being retried. *usually* the name of a b2 operation.attemptsSoFar
- how many times have we called callable.call() so far?tookMillis
- how long did this attempt take?e
- the unretryable exception.
-
gotUnexpectedUnretryable
default void gotUnexpectedUnretryable(java.lang.String operation, int attemptsSoFar, long tookMillis, java.lang.Exception e)
Callable.call() threw an Exception that wasn't a B2Exception. No more attempts will be made.- Parameters:
operation
- the name of what is being retried. *usually* the name of a b2 operation.attemptsSoFar
- how many times have we called callable.call() so far?tookMillis
- how long did this attempt take?e
- the unexpected, unretryable exception.
-
-