Table of Contents

Class StandardRetryPolicy

Namespace
Amazon.Runtime.Internal
Assembly
AWSSDK.Core.dll

The default implementation of the standard retry policy.

public class StandardRetryPolicy : RetryPolicy
Inheritance
StandardRetryPolicy
Derived
Inherited Members

Constructors

StandardRetryPolicy(IClientConfig)

Constructor for StandardRetryPolicy.

public StandardRetryPolicy(IClientConfig config)

Parameters

config IClientConfig

The Client config object. This is used to retrieve the maximum number of retries before throwing back a exception(This does not count the initial request) and the service URL for the request.

StandardRetryPolicy(int)

Constructor for StandardRetryPolicy.

public StandardRetryPolicy(int maxRetries)

Parameters

maxRetries int

The maximum number of retries before throwing back a exception. This does not count the initial request.

Properties

CapacityManagerInstance

protected static CapacityManager CapacityManagerInstance { get; set; }

Property Value

CapacityManager

MaxBackoffInMilliseconds

The maximum value of exponential backoff in milliseconds, which will be used to wait before retrying a request. The default is 20000 milliseconds.

public int MaxBackoffInMilliseconds { get; set; }

Property Value

int

Methods

CalculateRetryDelay(int, int)

protected static int CalculateRetryDelay(int retries, int maxBackoffInMilliseconds)

Parameters

retries int
maxBackoffInMilliseconds int

Returns

int

CanRetry(IExecutionContext)

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

public override bool CanRetry(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

Returns

bool

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

NotifySuccess(IExecutionContext)

Virtual method that gets called on a success Response. If its a retry success response, the entire retry acquired capacity is released(default is 5). If its just a success response a lesser value capacity is released(default is 1).

public override void NotifySuccess(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

OnRetry(IExecutionContext)

Virtual method that gets called when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.

public override 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 when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.

public override 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 when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.

public override 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 throtting error

Returns

bool

RetryForException(IExecutionContext, Exception)

Return true if the request should be retried.

public override bool RetryForException(IExecutionContext executionContext, Exception exception)

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

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.

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

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

exception Exception

The exception thrown by the previous request.

Returns

Task<bool>

Return true if the request should be retried.

RetryForExceptionSync(Exception)

Perform the processor-bound portion of the RetryForException logic. This is shared by the sync, async, and APM versions of the RetryForException method.

protected bool RetryForExceptionSync(Exception exception)

Parameters

exception Exception

The exception thrown by the previous request.

Returns

bool

Return true if the request should be retried.

RetryForExceptionSync(Exception, IExecutionContext)

Perform the processor-bound portion of the RetryForException logic. This is shared by the sync, async, and APM versions of the RetryForException method.

protected bool RetryForExceptionSync(Exception exception, IExecutionContext executionContext)

Parameters

exception Exception

The exception thrown by the previous request.

executionContext IExecutionContext

Request context containing the state of the request.

Returns

bool

Return true if the request should be retried.

RetryLimitReached(IExecutionContext)

Checks if the retry limit is reached.

public override bool RetryLimitReached(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

Returns

bool

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

WaitBeforeRetry(IExecutionContext)

Waits before retrying a request. The default policy implements a exponential backoff with jitter algorithm.

public override void WaitBeforeRetry(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

Request context containing the state of the request.

WaitBeforeRetry(int, int)

Waits for an amount of time using an exponential backoff with jitter algorithm.

public static void WaitBeforeRetry(int retries, int maxBackoffInMilliseconds)

Parameters

retries int

The request retry index. The first request is expected to be 0 while the first retry will be 1.

maxBackoffInMilliseconds int

The max number of milliseconds to wait

WaitBeforeRetryAsync(IExecutionContext)

Waits before retrying a request.

public override Task WaitBeforeRetryAsync(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

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

Returns

Task