RetryStrategy Class
- java.
lang. Object - com.
microsoft. azure. elasticdb. core. commons. transientfaulthandling. RetryStrategy
- com.
public class RetryStrategy
Represents a retry strategy that determines the number of retry attempts and the interval between retries.
Field Summary
Modifier and Type | Field and Description |
---|---|
final Duration |
DEFAULT_CLIENT_BACKOFF
Represents the default amount of time used when calculating a random delta in the exponential delay between retries. |
final int |
DEFAULT_CLIENT_RETRY_COUNT
region Public members Represents the default number of retry attempts. |
final boolean |
DEFAULT_FIRST_FAST_RETRY
Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval. |
final Duration |
DEFAULT_MAX_BACKOFF
Represents the default maximum amount of time used when calculating the exponential delay between retries. |
final Duration |
DEFAULT_MIN_BACKOFF
Represents the default minimum amount of time used when calculating the exponential delay between retries. |
final Duration |
DEFAULT_RETRY_INCREMENT
Represents the default time increment between retry attempts in the progressive delay policy. |
final Duration |
DEFAULT_RETRY_INTERVAL
Represents the default interval between retries. |
Constructor Summary
Constructor | Description |
---|---|
RetryStrategy(String name, boolean firstFastRetry) |
Initializes a new instance of the RetryStrategy class. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Retry |
getDefaultExponential()
Returns a default policy that implements a random exponential retry interval configured with the DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_MIN_BACKOFF, DEFAULT_MAX_BACKOFF, and DEFAULT_CLIENT_BACKOFF parameters. 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_CLIENT_RETRY_COUNT and DEFAULT_RETRY_INTERVAL parameters. 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_CLIENT_RETRY_COUNT, DEFAULT_RETRY_INTERVAL, and DEFAULT_RETRY_INCREMENT parameters. The default retry policy treats all caught exceptions as transient errors. |
final boolean | getFastFirstRetry() |
final String | getName() |
Retry |
getNoRetry()
Returns a default policy that performs no retries, but invokes the action only once. |
abstract Should |
getShouldRetry()
Returns the corresponding ShouldRetry delegate. |
final void | setFastFirstRetry(boolean value) |
Field Details
DEFAULT_CLIENT_BACKOFF
public static final Duration DEFAULT_CLIENT_BACKOFF= Duration.ofSeconds(10)
Represents the default amount of time used when calculating a random delta in the exponential delay between retries.
DEFAULT_CLIENT_RETRY_COUNT
public static final int DEFAULT_CLIENT_RETRY_COUNT= 10
region Public members
Represents the default number of retry attempts.
DEFAULT_FIRST_FAST_RETRY
public static final boolean DEFAULT_FIRST_FAST_RETRY= true
Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.
DEFAULT_MAX_BACKOFF
public static final Duration DEFAULT_MAX_BACKOFF= Duration.ofSeconds(30)
Represents the default maximum amount of time used when calculating the exponential delay between retries.
DEFAULT_MIN_BACKOFF
public static final Duration DEFAULT_MIN_BACKOFF= Duration.ofSeconds(1)
Represents the default minimum amount of time used when calculating the exponential delay between retries.
DEFAULT_RETRY_INCREMENT
public static final Duration DEFAULT_RETRY_INCREMENT= Duration.ofSeconds(1)
Represents the default time increment between retry attempts in the progressive delay policy.
DEFAULT_RETRY_INTERVAL
public static final Duration DEFAULT_RETRY_INTERVAL= Duration.ofSeconds(1)
Represents the default interval between retries.
Constructor Details
RetryStrategy
protected RetryStrategy(String name, boolean firstFastRetry)
Initializes a new instance of the RetryStrategy class.
Parameters:
Method Details
getDefaultExponential
public static RetryStrategy getDefaultExponential()
Returns a default policy that implements a random exponential retry interval configured with the DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_MIN_BACKOFF, DEFAULT_MAX_BACKOFF, and DEFAULT_CLIENT_BACKOFF parameters. The default retry policy treats all caught exceptions as transient errors.
getDefaultFixed
public static RetryStrategy getDefaultFixed()
Returns a default policy that implements a fixed retry interval configured with the DEFAULT_CLIENT_RETRY_COUNT and DEFAULT_RETRY_INTERVAL parameters. The default retry policy treats all caught exceptions as transient errors.
getDefaultProgressive
public static RetryStrategy getDefaultProgressive()
Returns a default policy that implements a progressive retry interval configured with the DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_RETRY_INTERVAL, and DEFAULT_RETRY_INCREMENT parameters. The default retry policy treats all caught exceptions as transient errors.
getFastFirstRetry
public final boolean getFastFirstRetry()
getName
public final String getName()
getNoRetry
public static RetryStrategy getNoRetry()
Returns a default policy that performs no retries, but invokes the action only once.
getShouldRetry
public abstract ShouldRetry getShouldRetry()
Returns the corresponding ShouldRetry delegate.
Returns:
setFastFirstRetry
public final void setFastFirstRetry(boolean value)
Parameters: