public class RetryableStageHelper extends Object
RetryableStage
and AsyncRetryableStage
when querying and interacting with a
RetryPolicy
.Modifier and Type | Field and Description |
---|---|
static ExecutionAttribute<Duration> |
LAST_BACKOFF_DELAY_DURATION |
Constructor and Description |
---|
RetryableStageHelper(SdkHttpFullRequest request,
RequestExecutionContext context,
HttpClientDependencies dependencies) |
Modifier and Type | Method and Description |
---|---|
void |
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 |
attemptSucceeded()
Notify the retry policy that the request attempt succeeded.
|
int |
getAttemptNumber()
Retrieve the current attempt number, updated whenever
startingAttempt() is invoked. |
Duration |
getBackoffDelay()
Get the amount of time that the request should be delayed before being sent.
|
SdkException |
getLastException()
Retrieve the last call failure exception encountered by this execution, updated whenever
setLastException(java.lang.Throwable) is
invoked. |
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 |
logSendingRequest()
Log a message to the user at the debug level to indicate that we are sending the request to the service.
|
SdkHttpFullRequest |
requestToSend()
Retrieve the request to send to the service, including any detailed retry information headers.
|
boolean |
retryPolicyAllowsRetry()
Returns true if the retry policy allows this attempt.
|
SdkException |
retryPolicyDisallowedRetryException()
Return the exception that should be thrown, because the retry policy did not allow the request to be retried.
|
void |
setLastException(Throwable lastException)
Update the
getLastException() value for this helper. |
void |
setLastResponse(SdkHttpResponse lastResponse)
Set the last HTTP response returned by the service.
|
void |
startingAttempt()
Invoke when starting a request attempt, before querying the retry policy.
|
public static final ExecutionAttribute<Duration> LAST_BACKOFF_DELAY_DURATION
public RetryableStageHelper(SdkHttpFullRequest request, RequestExecutionContext context, HttpClientDependencies dependencies)
public void startingAttempt()
public boolean retryPolicyAllowsRetry()
public SdkException retryPolicyDisallowedRetryException()
public Duration getBackoffDelay()
Duration.ZERO
, such as
for the first request in the request series.public void logBackingOff(Duration backoffDelay)
public SdkHttpFullRequest requestToSend()
public void logSendingRequest()
public void adjustClockIfClockSkew(Response<?> response)
public void attemptSucceeded()
public int getAttemptNumber()
startingAttempt()
is invoked.public SdkException getLastException()
setLastException(java.lang.Throwable)
is
invoked.public void setLastException(Throwable lastException)
getLastException()
value for this helper. This will be used to determine whether the request should
be retried.public void setLastResponse(SdkHttpResponse lastResponse)
Copyright © 2020. All rights reserved.