Partilhar via


RetryPolicy Class

  • java.lang.Object
    • com.microsoft.azure.elasticdb.core.commons.transientfaulthandling.RetryPolicy

public class RetryPolicy

Provides the base implementation of the retry mechanism for unreliable actions and transient conditions.

Field Summary

Modifier and Type Field and Description
Event<EventHandler<RetryingEventArgs>> retrying

An instance of a callback delegate that will be invoked whenever a retry condition is encountered.

Constructor Summary

Constructor Description
RetryPolicy(int retryCount, Duration minBackOff, Duration maxBackOff, Duration deltaBackOff)

Initializes an instance of the RetryPolicy class.

RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and default fixed time interval between retries.

RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration retryInterval)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and fixed time interval between retries.

RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration initialInterval, Duration increment)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration minBackoff, Duration maxBackoff, Duration deltaBackoff)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and backoff parameters for calculating the exponential delay between retries.

RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, RetryStrategy retryStrategy)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

Method Summary

Modifier and Type Method and Description
<ResultT> ResultT executeAction(Callable<ResultT> callable)

Repetitively executes the specified action while it satisfies the current retry policy.

void executeAction(Runnable action)

Repetitively executes the specified action while it satisfies the current retry policy.

RetryPolicy getDefaultExponential()

Returns a default policy that implements a random exponential retry interval configured with the default FixedInterval retry strategy. The default retry policy treats all caught exceptions as transient errors.

RetryPolicy getDefaultFixed()

Returns a default policy that implements a fixed retry interval configured with the default FixedInterval retry strategy. The default retry policy treats all caught exceptions as transient errors.

RetryPolicy getDefaultProgressive()

Returns a default policy that implements a progressive retry interval configured with the default Incremental retry strategy. The default retry policy treats all caught exceptions as transient errors.

RetryPolicy getDefaultRetryPolicy()

Gets the default retry policy. 5 retries at 1 second intervals.

Duration getDeltaBackOff()
final ITransientErrorDetectionStrategy getErrorDetectionStrategy()
RetryStrategy getExponentialRetryStrategy()

Marshals this instance into the TFH library RetryStrategy type.

Duration getMaxBackOff()
Duration getMinBackOff()
RetryPolicy getNoRetry()

Returns a default policy that performs no retries, but invokes the action only once.

int getRetryCount()
final RetryStrategy getRetryStrategy()
String toString()

String representation of RetryPolicy.

Field Details

retrying

public Event> retrying

An instance of a callback delegate that will be invoked whenever a retry condition is encountered.

Constructor Details

RetryPolicy

public RetryPolicy(int retryCount, Duration minBackOff, Duration maxBackOff, Duration deltaBackOff)

Initializes an instance of the RetryPolicy class.

Parameters:

retryCount - The number of retry attempts.
minBackOff - Minimum backoff time for exponential backoff policy.
maxBackOff - Maximum backoff time for exponential backoff policy.
deltaBackOff - Delta backoff time for exponential backoff policy.

RetryPolicy

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and default fixed time interval between retries.

Parameters:

errorDetectionStrategy - The ITransientErrorDetectionStrategy that is responsible for detecting transient conditions.
retryCount - The number of retry attempts.

RetryPolicy

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration retryInterval)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and fixed time interval between retries.

Parameters:

errorDetectionStrategy - The ITransientErrorDetectionStrategy that is responsible for detecting transient conditions.
retryCount - The number of retry attempts.
retryInterval - The interval between retries.

RetryPolicy

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration initialInterval, Duration increment)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

Parameters:

errorDetectionStrategy - The ITransientErrorDetectionStrategy that is responsible for detecting transient conditions.
retryCount - The number of retry attempts.
initialInterval - The initial interval that will apply for the first retry.
increment - The incremental time value that will be used to calculate the progressive delay between retries.

RetryPolicy

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, Duration minBackoff, Duration maxBackoff, Duration deltaBackoff)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and backoff parameters for calculating the exponential delay between retries.

Parameters:

errorDetectionStrategy - The ITransientErrorDetectionStrategy that is responsible for detecting transient conditions.
retryCount - The number of retry attempts.
minBackoff - The minimum backoff time.
maxBackoff - The maximum backoff time.
deltaBackoff - The time value that will be used to calculate a random delta in the exponential delay between retries.

RetryPolicy

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, RetryStrategy retryStrategy)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

Parameters:

errorDetectionStrategy - The ITransientErrorDetectionStrategy that is responsible for detecting transient conditions.
retryStrategy - The strategy to use for this retry policy.

Method Details

executeAction

public ResultT executeAction(Callable callable)

Repetitively executes the specified action while it satisfies the current retry policy.

Parameters:

callable - A delegate that represents the executable action that returns the result of type ResultT .

Returns:

The result from the action.

executeAction

public void executeAction(Runnable action)

Repetitively executes the specified action while it satisfies the current retry policy.

Parameters:

action - A delegate that represents the executable action that doesn't return any results.

getDefaultExponential

public static RetryPolicy getDefaultExponential()

Returns a default policy that implements a random exponential retry interval configured with the default FixedInterval retry strategy. The default retry policy treats all caught exceptions as transient errors.

getDefaultFixed

public static RetryPolicy getDefaultFixed()

Returns a default policy that implements a fixed retry interval configured with the default FixedInterval retry strategy. The default retry policy treats all caught exceptions as transient errors.

getDefaultProgressive

public static RetryPolicy getDefaultProgressive()

Returns a default policy that implements a progressive retry interval configured with the default Incremental retry strategy. The default retry policy treats all caught exceptions as transient errors.

getDefaultRetryPolicy

public static RetryPolicy getDefaultRetryPolicy()

Gets the default retry policy. 5 retries at 1 second intervals.

getDeltaBackOff

public Duration getDeltaBackOff()

getErrorDetectionStrategy

public final ITransientErrorDetectionStrategy getErrorDetectionStrategy()

getExponentialRetryStrategy

public RetryStrategy getExponentialRetryStrategy()

Marshals this instance into the TFH library RetryStrategy type.

Returns:

The RetryStrategy

getMaxBackOff

public Duration getMaxBackOff()

getMinBackOff

public Duration getMinBackOff()

getNoRetry

public static RetryPolicy getNoRetry()

Returns a default policy that performs no retries, but invokes the action only once.

getRetryCount

public int getRetryCount()

getRetryStrategy

public final RetryStrategy getRetryStrategy()

toString

public String toString()

String representation of RetryPolicy.

Applies to