你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

RetryStrategy Class

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

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
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.

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.

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.

final boolean getFastFirstRetry()
final String getName()
RetryStrategy getNoRetry()

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

abstract ShouldRetry 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:

name - The name of the retry strategy.
firstFastRetry - true to immediately retry in the first attempt; otherwise, false. The subsequent retries will remain subject to the configured retry interval.

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:

The ShouldRetry delegate.

setFastFirstRetry

public final void setFastFirstRetry(boolean value)

Parameters:

value

Applies to