java.lang.Object
software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper

@SdkInternalApi public final class RetryableStageHelper extends Object
Contains the logic shared by RetryableStage and AsyncRetryableStage when querying and interacting with a RetryStrategy.
  • Field Details

  • Constructor Details

  • Method Details

    • startingAttempt

      public void startingAttempt()
      Invoke when starting a request attempt, before querying the retry policy.
    • acquireInitialToken

      public Duration 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 returns Duration.ZERO if the calling code does not have to wait. As of today the only strategy that might return a non-zero value is AdaptiveRetryStrategy.
    • recordAttemptSucceeded

      public void recordAttemptSucceeded()
      Notify the retry strategy that the request attempt succeeded.
    • tryRefreshToken

      public Either<Duration,Duration> tryRefreshToken(Duration suggestedDelay)
      Invoked after a failed attempt and before retrying. The returned Either will 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

      public SdkException retryPolicyDisallowedRetryException()
      Return the exception that should be thrown, because the retry strategy did not allow the request to be retried.
    • logBackingOff

      public 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.
    • logAcquireFailureBackingOff

      public void logAcquireFailureBackingOff(Duration acquireFailureBackoffDelay)
    • requestToSend

      public SdkHttpFullRequest 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

      public 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. This will allow a retried request to be signed with what is likely to be a more accurate time.
    • getLastException

      public SdkException getLastException()
      Retrieve the last call failure exception encountered by this execution, updated whenever setLastException(java.lang.Throwable) is invoked.
    • setLastException

      public void setLastException(Throwable lastException)
      Update the getLastException() value for this helper. This will be used to determine whether the request should be retried.
    • setLastResponse

      public void setLastResponse(SdkHttpResponse lastResponse)
      Set the last HTTP response returned by the service. This will be used to determine whether the request should be retried.
    • getLastResponse

      public SdkHttpResponse getLastResponse()
    • getAttemptNumber

      public int getAttemptNumber()
      Retrieve the current attempt number, updated whenever startingAttempt() is invoked.