Class TokenBucketRetryCondition

java.lang.Object
software.amazon.awssdk.core.retry.conditions.TokenBucketRetryCondition
All Implemented Interfaces:
RetryCondition

public class TokenBucketRetryCondition extends Object implements RetryCondition
A RetryCondition that limits the number of retries made by the SDK using a token bucket algorithm. "Tokens" are acquired from the bucket whenever shouldRetry(software.amazon.awssdk.core.retry.RetryPolicyContext) returns true, and are released to the bucket whenever requestSucceeded(software.amazon.awssdk.core.retry.RetryPolicyContext) or requestWillNotBeRetried(software.amazon.awssdk.core.retry.RetryPolicyContext) are invoked.

If "tokens" cannot be acquired from the bucket, it means too many requests have failed and the request will not be allowed to retry until we start to see initial non-retried requests succeed via requestSucceeded(RetryPolicyContext).

This prevents the client from holding the calling thread to retry when it's likely that it will fail anyway.

This is currently included in the default RetryPolicy.aggregateRetryCondition(), but can be disabled by setting the RetryPolicy.Builder.retryCapacityCondition(software.amazon.awssdk.core.retry.conditions.RetryCondition) to null.