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
RetryStrategy.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRetryableStageHelper(SdkHttpFullRequest request, RequestExecutionContext context, HttpClientDependencies dependencies) -
Method Summary
Modifier and TypeMethodDescriptionInvoke when starting the first attempt.voidadjustClockIfClockSkew(Response<?> response) Adjust the client-side clock skew if the provided response indicates that there is a large skew between the client and service.intRetrieve the current attempt number, updated wheneverstartingAttempt()is invoked.Retrieve the last call failure exception encountered by this execution, updated wheneversetLastException(java.lang.Throwable)is invoked.voidlogAcquireFailureBackingOff(Duration acquireFailureBackoffDelay) voidlogBackingOff(Duration backoffDelay) Log a message to the user at the debug level to indicate how long we will wait before retrying the request.voidLog a message to the user at the debug level to indicate that we are sending the request to the service.voidNotify the retry strategy that the request attempt succeeded.Retrieve the request to send to the service, including any detailed retry information headers.Return the exception that should be thrown, because the retry strategy did not allow the request to be retried.voidsetLastException(Throwable lastException) Update thegetLastException()value for this helper.voidsetLastResponse(SdkHttpResponse lastResponse) Set the last HTTP response returned by the service.voidInvoke when starting a request attempt, before querying the retry policy.tryRefreshToken(Duration suggestedDelay) Invoked after a failed attempt and before retrying.
-
Field Details
-
SDK_RETRY_INFO_HEADER
- See Also:
-
LAST_BACKOFF_DELAY_DURATION
-
-
Constructor Details
-
RetryableStageHelper
public RetryableStageHelper(SdkHttpFullRequest request, RequestExecutionContext context, HttpClientDependencies dependencies)
-
-
Method Details
-
startingAttempt
public void startingAttempt()Invoke when starting a request attempt, before querying the retry policy. -
acquireInitialToken
Invoke when starting the first attempt. This method will acquire the initial token and store it as an execution attribute. This method returns a delay that the caller have to wait before attempting the first request. If this method returnsDuration.ZEROif the calling code does not have to wait. As of today the only strategy that might return a non-zero value isAdaptiveRetryStrategy. -
recordAttemptSucceeded
public void recordAttemptSucceeded()Notify the retry strategy that the request attempt succeeded. -
tryRefreshToken
Invoked after a failed attempt and before retrying. The returnedEitherwill have its left be populated if the refresh is successful. The right is populated if the refresh is unsuccessful. In either case, the calling code is expected to wait the delay represented in the duration before retrying the request or exiting the retry loop.- Parameters:
suggestedDelay- A suggested delay, presumably coming from the server response. The response when present will be at least this amount.- Returns:
- An optional time to wait, regardless of whether the refresh is successful. If the left value is present, the retry strategy allowed the retry. If the right value is present the retry strategy disallowed the retry and the calling code should not retry.
-
retryPolicyDisallowedRetryException
Return the exception that should be thrown, because the retry strategy did not allow the request to be retried. -
logBackingOff
Log a message to the user at the debug level to indicate how long we will wait before retrying the request. -
logAcquireFailureBackingOff
-
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. -
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. -
getLastResponse
-
getAttemptNumber
public int getAttemptNumber()Retrieve the current attempt number, updated wheneverstartingAttempt()is invoked.
-