Table of Contents

Class ExponentialRetry

Namespace
Microsoft.WindowsAzure.Storage.RetryPolicies
Assembly
Microsoft.WindowsAzure.Storage.dll

Represents a retry policy that performs a specified number of retries, using a randomized exponential back off scheme to determine the interval between retries.

public sealed class ExponentialRetry : IExtendedRetryPolicy, IRetryPolicy
Inheritance
ExponentialRetry
Implements
Inherited Members

Constructors

ExponentialRetry()

Initializes a new instance of the ExponentialRetry class.

public ExponentialRetry()

ExponentialRetry(TimeSpan, int)

Initializes a new instance of the ExponentialRetry class using the specified delta and maximum number of retries.

public ExponentialRetry(TimeSpan deltaBackoff, int maxAttempts)

Parameters

deltaBackoff TimeSpan

A TimeSpan specifying the back-off interval between retries.

maxAttempts int

An integer specifying the maximum number of retry attempts.

Methods

CreateInstance()

Generates a new retry policy for the current request attempt.

public IRetryPolicy CreateInstance()

Returns

IRetryPolicy

An IRetryPolicy object that represents the retry policy for the current request attempt.

Evaluate(RetryContext, OperationContext)

Determines whether the operation should be retried and the interval until the next retry.

public RetryInfo Evaluate(RetryContext retryContext, OperationContext operationContext)

Parameters

retryContext RetryContext

A RetryContext object that indicates the number of retries, the results of the last request, and whether the next retry should happen in the primary or secondary location, and specifies the location mode.

operationContext OperationContext

An OperationContext object that represents the context for the current operation.

Returns

RetryInfo

A RetryInfo object that indicates the location mode, and whether the next retry should happen in the primary or secondary location. If null, the operation will not be retried.

ShouldRetry(int, int, Exception, out TimeSpan, OperationContext)

Determines whether the operation should be retried and the interval until the next retry.

public bool ShouldRetry(int currentRetryCount, int statusCode, Exception lastException, out TimeSpan retryInterval, OperationContext operationContext)

Parameters

currentRetryCount int

An integer specifying the number of retries for the given operation. A value of zero signifies this is the first error encountered.

statusCode int

An integer containing the status code for the last operation.

lastException Exception

An Exception object that represents the last exception encountered.

retryInterval TimeSpan

A TimeSpan indicating the interval to wait until the next retry.

operationContext OperationContext

An OperationContext object that represents the context for the current operation.

Returns

bool

true if the operation should be retried; otherwise, false.