Class BaseRetryStrategy
java.lang.Object
software.amazon.awssdk.retries.internal.BaseRetryStrategy
- All Implemented Interfaces:
RetryStrategy,DefaultAwareRetryStrategy
- Direct Known Subclasses:
DefaultAdaptiveRetryStrategy,DefaultLegacyRetryStrategy,DefaultStandardRetryStrategy
@SdkInternalApi
public abstract class BaseRetryStrategy
extends Object
implements DefaultAwareRetryStrategy
Generic class that implements that common logic for all the retries strategies with extension points for specific strategies to
tailor the behavior to its needs.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BackoffStrategyprotected final booleanprotected final intprotected final Loggerprotected final intprotected final BackoffStrategyprotected final intprotected final TokenBucketStoreprotected final boolean -
Method Summary
Modifier and TypeMethodDescriptionThis method implements the logic ofRetryStrategy.acquireInitialToken(AcquireInitialTokenRequest).addDefaults(RetryStrategyDefaults retryStrategyDefaults) Add the specified defaults to this retry strategyprotected DurationComputes the backoff before exiting the retry loop using the configured backoff strategy.protected DurationcomputeBackoff(RefreshRetryTokenRequest request, DefaultRetryToken token) Computes the backoff before a retry using the configured backoff strategy.protected DurationComputes the backoff before the first attempt, by defaultDuration.ZERO.protected intexceptionCost(RefreshRetryTokenRequest request) Returns the amount of tokens to withdraw from the token bucket.final booleanReturns true if there are retry predicates configured for this retry strategy.intfinal RecordSuccessResponserecordSuccess(RecordSuccessRequest request) This method implements the logic ofRetryStrategy.recordSuccess(RecordSuccessRequest).This method implements the logic ofRetryStrategy.refreshRetryToken(RefreshRetryTokenRequest).booleanshouldAddDefaults(String defaultPredicateName) toString()protected voidCalled insiderefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)to allow extending classes to update their internal state before retrying a request.protected voidCalled insiderecordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest)to allow extending classes to update their internal state after a successful request.booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awssdk.retries.api.RetryStrategy
toBuilder
-
Field Details
-
log
-
retryPredicates
-
maxAttempts
protected final int maxAttempts -
circuitBreakerEnabled
protected final boolean circuitBreakerEnabled -
backoffStrategy
-
throttlingBackoffStrategy
-
treatAsThrottling
-
exceptionCost
protected final int exceptionCost -
throttlingExceptionCost
protected final int throttlingExceptionCost -
tokenBucketStore
-
defaultsAdded
-
useClientDefaults
protected final boolean useClientDefaults
-
-
Method Details
-
acquireInitialToken
This method implements the logic ofRetryStrategy.acquireInitialToken(AcquireInitialTokenRequest).- Specified by:
acquireInitialTokenin interfaceRetryStrategy- See Also:
-
refreshRetryToken
This method implements the logic ofRetryStrategy.refreshRetryToken(RefreshRetryTokenRequest).- Specified by:
refreshRetryTokenin interfaceRetryStrategy- See Also:
-
recordSuccess
This method implements the logic ofRetryStrategy.recordSuccess(RecordSuccessRequest).- Specified by:
recordSuccessin interfaceRetryStrategy- See Also:
-
maxAttempts
public int maxAttempts()- Specified by:
maxAttemptsin interfaceRetryStrategy
-
useClientDefaults
public boolean useClientDefaults()- Specified by:
useClientDefaultsin interfaceRetryStrategy
-
computeInitialBackoff
Computes the backoff before the first attempt, by defaultDuration.ZERO. Extending classes can override this method to compute a different duration depending on their logic. -
computeBackoff
Computes the backoff before a retry using the configured backoff strategy. Extending classes can override this method to compute a different duration depending on their logic. -
computeAcquireFailureBackoff
Computes the backoff before exiting the retry loop using the configured backoff strategy. Extending classes can override this method to compute a different duration depending on their logic. The default implementation returns 0 delay.- Parameters:
request- The refresh request that failed to acquire sufficient capacity.
-
updateStateForSuccess
Called insiderecordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest)to allow extending classes to update their internal state after a successful request. -
updateStateForRetry
Called insiderefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)to allow extending classes to update their internal state before retrying a request. -
exceptionCost
Returns the amount of tokens to withdraw from the token bucket. Extending classes can override this method to tailor this amount for the specific kind of failure. -
hasRetryPredicates
public final boolean hasRetryPredicates()Returns true if there are retry predicates configured for this retry strategy.- Returns:
- true if there are retry predicates configured for this retry strategy.
-
retryPredicates
-
shouldAddDefaults
-
addDefaults
Description copied from interface:DefaultAwareRetryStrategyAdd the specified defaults to this retry strategy- Specified by:
addDefaultsin interfaceDefaultAwareRetryStrategy- Parameters:
retryStrategyDefaults- the defaults to add to this strategy- Returns:
- a new retry strategy containing the specified defaults.
-
toString
-