Class RetryableStageHelper
java.lang.Object
software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper
Contains the logic shared by
RetryableStage
and AsyncRetryableStage
when querying and interacting with a
RetryPolicy
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionRetryableStageHelper
(SdkHttpFullRequest request, RequestExecutionContext context, RateLimitingTokenBucket rateLimitingTokenBucket, HttpClientDependencies dependencies) -
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustClockIfClockSkew
(Response<?> response) Adjust the client-side clock skew if the provided response indicates that there is a large skew between the client and service.void
Notify the retry policy that the request attempt succeeded.int
Retrieve the current attempt number, updated wheneverstartingAttempt()
is invoked.Get the amount of time that the request should be delayed before being sent.Retrieve the last call failure exception encountered by this execution, updated wheneversetLastException(java.lang.Throwable)
is invoked.void
Acquire a send token from the rate limiter.Acquire a send token from the rate limiter in a non blocking manner.boolean
Whether rate limiting should fast fail.boolean
void
logBackingOff
(Duration backoffDelay) Log a message to the user at the debug level to indicate how long we will wait before retrying the request.void
Log a message to the user at the debug level to indicate that we are sending the request to the service.Retrieve the request to send to the service, including any detailed retry information headers.boolean
Returns true if the retry policy allows this attempt.Return the exception that should be thrown, because the retry policy did not allow the request to be retried.void
setLastException
(Throwable lastException) Update thegetLastException()
value for this helper.void
setLastResponse
(SdkHttpResponse lastResponse) Set the last HTTP response returned by the service.void
Invoke when starting a request attempt, before querying the retry policy.void
Conditionally updates the sending rate of the rate limiter when an error response is received.void
Conditionally updates the sending rate of the rate limiter when an error response is received.
-
Field Details
-
SDK_RETRY_INFO_HEADER
- See Also:
-
LAST_BACKOFF_DELAY_DURATION
-
-
Constructor Details
-
RetryableStageHelper
public RetryableStageHelper(SdkHttpFullRequest request, RequestExecutionContext context, RateLimitingTokenBucket rateLimitingTokenBucket, HttpClientDependencies dependencies)
-
-
Method Details
-
startingAttempt
public void startingAttempt()Invoke when starting a request attempt, before querying the retry policy. -
retryPolicyAllowsRetry
public boolean retryPolicyAllowsRetry()Returns true if the retry policy allows this attempt. This will always return true if the current attempt is not a retry (i.e. it's the first request in the execution). -
retryPolicyDisallowedRetryException
Return the exception that should be thrown, because the retry policy did not allow the request to be retried. -
getBackoffDelay
Get the amount of time that the request should be delayed before being sent. This may beDuration.ZERO
, such as for the first request in the request series. -
logBackingOff
Log a message to the user at the debug level to indicate how long we will wait before retrying the request. -
requestToSend
Retrieve the request to send to the service, including any detailed retry information headers. -
logSendingRequest
public void logSendingRequest()Log a message to the user at the debug level to indicate that we are sending the request to the service. -
adjustClockIfClockSkew
Adjust the client-side clock skew if the provided response indicates that there is a large skew between the client and service. This will allow a retried request to be signed with what is likely to be a more accurate time. -
attemptSucceeded
public void attemptSucceeded()Notify the retry policy that the request attempt succeeded. -
getAttemptNumber
public int getAttemptNumber()Retrieve the current attempt number, updated wheneverstartingAttempt()
is invoked. -
getLastException
Retrieve the last call failure exception encountered by this execution, updated wheneversetLastException(java.lang.Throwable)
is invoked. -
setLastException
Update thegetLastException()
value for this helper. This will be used to determine whether the request should be retried. -
setLastResponse
Set the last HTTP response returned by the service. This will be used to determine whether the request should be retried. -
isFastFailRateLimiting
public boolean isFastFailRateLimiting()Whether rate limiting should fast fail. -
isLastExceptionThrottlingException
public boolean isLastExceptionThrottlingException() -
getSendToken
public void getSendToken()Acquire a send token from the rate limiter. Returns immediately if rate limiting is not enabled. -
getSendTokenNonBlocking
Acquire a send token from the rate limiter in a non blocking manner. SeeRateLimitingTokenBucket.acquireNonBlocking(double, boolean)
for documentation on how to interpret the returned value. -
updateClientSendingRateForErrorResponse
public void updateClientSendingRateForErrorResponse()Conditionally updates the sending rate of the rate limiter when an error response is received. This operation is a noop if rate limiting is not enabled. -
updateClientSendingRateForSuccessResponse
public void updateClientSendingRateForSuccessResponse()Conditionally updates the sending rate of the rate limiter when an error response is received. This operation is a noop if rate limiting is not enabled.
-