Table of Contents

Class RetryPolicy

Namespace
Amazon.Runtime
Assembly
AWSSDK.Core.dll

A retry policy specifies all aspects of retry behavior. This includes conditions when the request should be retried, checks of retry limit, preparing the request before retry and introducing delay (backoff) before retries.

public abstract class RetryPolicy
Inheritance
RetryPolicy
Derived
Inherited Members

Constructors

RetryPolicy()

protected RetryPolicy()

Properties

ErrorCodesToRetryOn

List of AWS specific error codes which are returned as part of the error response. These error codes will be retried.

public ICollection<string> ErrorCodesToRetryOn { get; protected set; }

Property Value

ICollection<string>

HttpStatusCodesToRetryOn

The standard set of transient error, HTTP status codes to retry on. 502 and 504 are returned by proxies. These can also be returned for S3 accelerate requests which are served by CloudFront.

public ICollection<HttpStatusCode> HttpStatusCodesToRetryOn { get; protected set; }

Property Value

ICollection<HttpStatusCode>

Logger

The logger used to log messages.

public ILogger Logger { get; set; }

Property Value

ILogger

MaxRetries

Maximum number of retries to be performed. This does not count the initial request.

public int MaxRetries { get; protected set; }

Property Value

int

RetryCapacity

This parameter serves as the value to the CapacityManager.Container datastructure. Its properties include the available capacity left for making a retry request and the maximum capacity size.

protected RetryCapacity RetryCapacity { get; set; }

Property Value

RetryCapacity

ThrottlingErrorCodes

The standard set of throttling error codes

public virtual ICollection<string> ThrottlingErrorCodes { get; protected set; }

Property Value

ICollection<string>

TimeoutErrorCodesToRetryOn

The standard set of timeout error codes to retry on.

public ICollection<string> TimeoutErrorCodesToRetryOn { get; protected set; }

Property Value

ICollection<string>

WebExceptionStatusesToRetryOn

Set of web exception status codes to retry on.

public ICollection<WebExceptionStatus> WebExceptionStatusesToRetryOn { get; protected set; }

Property Value

ICollection<WebExceptionStatus>

Methods

CanRetry(IExecutionContext)

Returns true if the request is in a state where it can be retried, else false.

public abstract bool CanRetry(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

Returns

bool

Returns true if the request is in a state where it can be retried, else false.

ContainErrorMessage(Exception, HashSet<string>)

protected static bool ContainErrorMessage(Exception exception, HashSet<string> errorMessages)

Parameters

exception Exception
errorMessages HashSet<string>

Returns

bool

GetRetryCapacityKey(IClientConfig)

Creates a key for storing retry capacity data. Key is based on service's url (we store retry capacity per service's url variant). If ClientConfig's ServiceURL override is set we use it as a key, otherwise we construct key based on ClientConfig's schema, region, service, fips, dualstack parameters. This value is unique key per real service's url variant.

protected static string GetRetryCapacityKey(IClientConfig config)

Parameters

config IClientConfig

Returns

string

IsServiceTimeoutError(Exception)

Determines if the exception is a known timeout error code that should be retried under the timeout error category.

public virtual bool IsServiceTimeoutError(Exception exception)

Parameters

exception Exception

The current exception to check.

Returns

bool

true if the exception is considered a timeout else false

IsThrottlingError(Exception)

Determines if an AmazonServiceException is a throttling error

public virtual bool IsThrottlingError(Exception exception)

Parameters

exception Exception

The current exception to check.

Returns

bool

true if it is a throttling error else false.

IsTransientError(IExecutionContext, Exception)

Determines if an AmazonServiceException is a transient error that should be retried.

public virtual bool IsTransientError(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The current execution context

exception Exception

The current exception to check.

Returns

bool

true if the exception is a transient error else false.

IsTransientSslError(Exception)

public static bool IsTransientSslError(Exception exception)

Parameters

exception Exception

Returns

bool

NotifySuccess(IExecutionContext)

Virtual method that gets called on a successful request response.

public virtual void NotifySuccess(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

ObtainSendToken(IExecutionContext, Exception)

This method uses a token bucket to enforce the maximum sending rate.

public virtual void ObtainSendToken(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

If the prior request failed, this exception is expected to be the exception that occurred during the prior request failure.

ObtainSendTokenAsync(IExecutionContext, Exception)

This method uses a token bucket to enforce the maximum sending rate.

public virtual Task ObtainSendTokenAsync(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

If the prior request failed, this exception is expected to be the exception that occurred during the prior request failure.

Returns

Task

OnRetry(IExecutionContext)

Virtual method that gets called before a retry request is initiated. The value returned is True by default(retry throttling feature is disabled).

public virtual bool OnRetry(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

Returns

bool

OnRetry(IExecutionContext, bool)

Virtual method that gets called before a retry request is initiated. The value returned is True by default(retry throttling feature is disabled).

public virtual bool OnRetry(IExecutionContext executionContext, bool bypassAcquireCapacity)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

bypassAcquireCapacity bool

true to bypass any attempt to acquire capacity on a retry

Returns

bool

OnRetry(IExecutionContext, bool, bool)

Virtual method that gets called before a retry request is initiated. The value returned is True by default(retry throttling feature is disabled).

public virtual bool OnRetry(IExecutionContext executionContext, bool bypassAcquireCapacity, bool isThrottlingError)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

bypassAcquireCapacity bool

true to bypass any attempt to acquire capacity on a retry

isThrottlingError bool

true if the error that will be retried is a throttling error

Returns

bool

Retry(IExecutionContext, Exception)

Checks if a retry should be performed with the given execution context and exception.

public bool Retry(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

The exception thrown after issuing the request.

Returns

bool

Returns true if the request should be retried, else false. The exception is retried if it matches with clockskew error codes.

RetryAsync(IExecutionContext, Exception)

Checks if a retry should be performed with the given execution context and exception.

public Task<bool> RetryAsync(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

The exception throw after issuing the request.

Returns

Task<bool>

Returns true if the request should be retried, else false. The exception is retried if it matches with clockskew error codes.

RetryForException(IExecutionContext, Exception)

Return true if the request should be retried for the given exception.

public abstract bool RetryForException(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

The exception thrown by the previous request.

Returns

bool

Return true if the request should be retried.

RetryForExceptionAsync(IExecutionContext, Exception)

Return true if the request should be retried for the given exception.

public abstract Task<bool> RetryForExceptionAsync(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

The exception thrown by the previous request.

Returns

Task<bool>

Return true if the request should be retried.

RetryLimitReached(IExecutionContext)

Checks if the retry limit is reached.

public abstract bool RetryLimitReached(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

Returns

bool

Return false if the request can be retried, based on number of retries.

WaitBeforeRetry(IExecutionContext)

Waits before retrying a request.

public abstract void WaitBeforeRetry(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

WaitBeforeRetryAsync(IExecutionContext)

Waits before retrying a request.

public abstract Task WaitBeforeRetryAsync(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

Returns

Task