RetryPolicy Class
- java.
lang. Object - com.
microsoft. azure. elasticdb. core. commons. transientfaulthandling. RetryPolicy
- com.
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<Retrying |
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. |
Retry |
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. |
Retry |
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. |
Retry |
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. |
Retry |
getDefaultRetryPolicy()
Gets the default retry policy. 5 retries at 1 second intervals. |
Duration | getDeltaBackOff() |
final ITransient |
getErrorDetectionStrategy() |
Retry |
getExponentialRetryStrategy()
Marshals this instance into the TFH library RetryStrategy type. |
Duration | getMaxBackOff() |
Duration | getMinBackOff() |
Retry |
getNoRetry()
Returns a default policy that performs no retries, but invokes the action only once. |
int | getRetryCount() |
final Retry |
getRetryStrategy() |
String |
toString()
String representation of RetryPolicy. |
Field Details
retrying
public Event
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:
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:
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:
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:
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:
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:
Method Details
executeAction
public
Repetitively executes the specified action while it satisfies the current retry policy.
Parameters:
Returns:
executeAction
public void executeAction(Runnable action)
Repetitively executes the specified action while it satisfies the current retry policy.
Parameters:
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:
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.