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
TimeSpanA TimeSpan specifying the back-off interval between retries.
maxAttempts
intAn 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
RetryContextA 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
OperationContextAn 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
intAn integer specifying the number of retries for the given operation. A value of zero signifies this is the first error encountered.
statusCode
intAn integer containing the status code for the last operation.
lastException
ExceptionAn Exception object that represents the last exception encountered.
retryInterval
TimeSpanA TimeSpan indicating the interval to wait until the next retry.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- bool
true
if the operation should be retried; otherwise,false
.