Class BaseRetryStrategy
- java.lang.Object
-
- software.amazon.awssdk.retries.internal.BaseRetryStrategy
-
- All Implemented Interfaces:
RetryStrategy
- Direct Known Subclasses:
DefaultAdaptiveRetryStrategy,DefaultLegacyRetryStrategy,DefaultStandardRetryStrategy
public abstract class BaseRetryStrategy extends Object implements RetryStrategy
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected BackoffStrategybackoffStrategyprotected booleancircuitBreakerEnabledprotected intexceptionCostprotected Loggerlogprotected intmaxAttemptsprotected List<Predicate<Throwable>>retryPredicatesprotected BackoffStrategythrottlingBackoffStrategyprotected TokenBucketStoretokenBucketStoreprotected Predicate<Throwable>treatAsThrottling
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AcquireInitialTokenResponseacquireInitialToken(AcquireInitialTokenRequest request)This method implements the logic ofRetryStrategy.acquireInitialToken(AcquireInitialTokenRequest).protected DurationcomputeBackoff(RefreshRetryTokenRequest request, DefaultRetryToken token)Computes the backoff before a retry using the configured backoff strategy.protected DurationcomputeInitialBackoff(AcquireInitialTokenRequest request)Computes the backoff before the first attempt, by defaultDuration.ZERO.protected intexceptionCost(RefreshRetryTokenRequest request)Returns the amount of tokens to withdraw from the token bucket.booleanhasRetryPredicates()Returns true if there are retry predicates configured for this retry strategy.intmaxAttempts()RecordSuccessResponserecordSuccess(RecordSuccessRequest request)This method implements the logic ofRetryStrategy.recordSuccess(RecordSuccessRequest).RefreshRetryTokenResponserefreshRetryToken(RefreshRetryTokenRequest request)This method implements the logic ofRetryStrategy.refreshRetryToken(RefreshRetryTokenRequest).protected voidupdateStateForRetry(RefreshRetryTokenRequest request)Called insiderefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)to allow extending classes to update their internal state before retrying a request.protected voidupdateStateForSuccess(DefaultRetryToken token)Called insiderecordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest)to allow extending classes to update their internal state after a successful request.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.retries.api.RetryStrategy
toBuilder
-
-
-
-
Field Detail
-
log
protected final Logger log
-
maxAttempts
protected final int maxAttempts
-
circuitBreakerEnabled
protected final boolean circuitBreakerEnabled
-
backoffStrategy
protected final BackoffStrategy backoffStrategy
-
throttlingBackoffStrategy
protected final BackoffStrategy throttlingBackoffStrategy
-
exceptionCost
protected final int exceptionCost
-
tokenBucketStore
protected final TokenBucketStore tokenBucketStore
-
-
Method Detail
-
acquireInitialToken
public final AcquireInitialTokenResponse acquireInitialToken(AcquireInitialTokenRequest request)
This method implements the logic ofRetryStrategy.acquireInitialToken(AcquireInitialTokenRequest).- Specified by:
acquireInitialTokenin interfaceRetryStrategy- See Also:
RetryStrategy.acquireInitialToken(AcquireInitialTokenRequest)
-
refreshRetryToken
public final RefreshRetryTokenResponse refreshRetryToken(RefreshRetryTokenRequest request)
This method implements the logic ofRetryStrategy.refreshRetryToken(RefreshRetryTokenRequest).- Specified by:
refreshRetryTokenin interfaceRetryStrategy- See Also:
RetryStrategy.refreshRetryToken(RefreshRetryTokenRequest)
-
recordSuccess
public final RecordSuccessResponse recordSuccess(RecordSuccessRequest request)
This method implements the logic ofRetryStrategy.recordSuccess(RecordSuccessRequest).- Specified by:
recordSuccessin interfaceRetryStrategy- See Also:
RetryStrategy.recordSuccess(RecordSuccessRequest)
-
maxAttempts
public int maxAttempts()
- Specified by:
maxAttemptsin interfaceRetryStrategy
-
computeInitialBackoff
protected Duration computeInitialBackoff(AcquireInitialTokenRequest request)
Computes the backoff before the first attempt, by defaultDuration.ZERO. Extending classes can override this method to compute different a different depending on their logic.
-
computeBackoff
protected Duration computeBackoff(RefreshRetryTokenRequest request, DefaultRetryToken token)
Computes the backoff before a retry using the configured backoff strategy. Extending classes can override this method to compute different a different depending on their logic.
-
updateStateForSuccess
protected void updateStateForSuccess(DefaultRetryToken token)
Called insiderecordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest)to allow extending classes to update their internal state after a successful request.
-
updateStateForRetry
protected void updateStateForRetry(RefreshRetryTokenRequest request)
Called insiderefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)to allow extending classes to update their internal state before retrying a request.
-
exceptionCost
protected int exceptionCost(RefreshRetryTokenRequest request)
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.
-
-