다음을 통해 공유


RetryPolicy Class

public class RetryPolicy implements RetryPolicyFactory

Abstract class that represents a retry policy.

Field Summary

Modifier and Type Field and Description
final int DEFAULT_CLIENT_BACKOFF

Represents the default client backoff interval, in milliseconds.

final int DEFAULT_CLIENT_RETRY_COUNT

Represents the default client retry count.

final int DEFAULT_MAX_BACKOFF

Represents the default maximum backoff interval, in milliseconds.

final int DEFAULT_MIN_BACKOFF

Represents the default minimum backoff interval, in milliseconds.

int deltaBackoffIntervalInMs

Represents the realized backoff interval, in milliseconds.

Date lastPrimaryAttempt

Represents the time of the last request attempt to the primary location.

Date lastSecondaryAttempt

Represents the time of the last request attempt to the secondary location.

int maximumAttempts

Represents the maximum retries that the retry policy should attempt.

Constructor Summary

Constructor Description
RetryPolicy()

Creates an instance of the class.

RetryPolicy(final int deltaBackoff, final int maxAttempts)

Creates an instance of the class using the specified delta backoff and maximum retry attempts.

Method Summary

Modifier and Type Method and Description
abstract RetryInfo evaluate(RetryContext retryContext, OperationContext operationContext)

Determines whether the operation should be retried and specifies the interval until the next retry.

boolean evaluateLastAttemptAndSecondaryNotFound(RetryContext retryContext)

Determines the time of the last attempt to a storage location and returns a that specifies if a request that was sent to the secondary location failed with 404.

RetryInfo evaluateRetryInfo(final RetryContext retryContext, final boolean secondaryNotFound, final long retryInterval)

Determines the RetryInfo object that indicates whether the next retry will happen in the primary or secondary location, and specifies the location mode.

Inherited Members

Field Details

DEFAULT_CLIENT_BACKOFF

public static final int DEFAULT_CLIENT_BACKOFF= 1000 * 30

Represents the default client backoff interval, in milliseconds.

DEFAULT_CLIENT_RETRY_COUNT

public static final int DEFAULT_CLIENT_RETRY_COUNT= 3

Represents the default client retry count.

DEFAULT_MAX_BACKOFF

public static final int DEFAULT_MAX_BACKOFF= 1000 * 90

Represents the default maximum backoff interval, in milliseconds.

DEFAULT_MIN_BACKOFF

public static final int DEFAULT_MIN_BACKOFF= 1000 * 3

Represents the default minimum backoff interval, in milliseconds.

deltaBackoffIntervalInMs

protected int deltaBackoffIntervalInMs

Represents the realized backoff interval, in milliseconds.

lastPrimaryAttempt

protected Date lastPrimaryAttempt= null

Represents the time of the last request attempt to the primary location.

lastSecondaryAttempt

protected Date lastSecondaryAttempt= null

Represents the time of the last request attempt to the secondary location.

maximumAttempts

protected int maximumAttempts

Represents the maximum retries that the retry policy should attempt.

Constructor Details

RetryPolicy

public RetryPolicy()

Creates an instance of the class.

RetryPolicy

public RetryPolicy(final int deltaBackoff, final int maxAttempts)

Creates an instance of the class using the specified delta backoff and maximum retry attempts.

Parameters:

deltaBackoff - The backoff interval, in milliseconds, between retries.
maxAttempts - The maximum number of retry attempts.

Method Details

evaluate

public abstract RetryInfo evaluate(RetryContext retryContext, OperationContext operationContext)

Determines whether the operation should be retried and specifies the interval until the next retry.

Parameters:

retryContext - A RetryContext object that indicates the number of retries, last request's results, whether the next retry should happen in the primary or secondary location, and specifies the location mode.
operationContext - An OperationContext object for tracking the current operation.

Returns:

A RetryInfo object that indicates whether the next retry will happen in the primary or secondary location, and specifies the location mode. If null, the operation will not be retried.

evaluateLastAttemptAndSecondaryNotFound

protected boolean evaluateLastAttemptAndSecondaryNotFound(RetryContext retryContext)

Determines the time of the last attempt to a storage location and returns a that specifies if a request that was sent to the secondary location failed with 404.

Parameters:

retryContext - A RetryContext object that indicates the number of retries, last request's results, whether the next retry should happen in the primary or secondary location, and specifies the location mode.

Returns:

true if a request sent to the secondary location fails with 404 (Not Found). false otherwise.

evaluateRetryInfo

protected RetryInfo evaluateRetryInfo(final RetryContext retryContext, final boolean secondaryNotFound, final long retryInterval)

Determines the RetryInfo object that indicates whether the next retry will happen in the primary or secondary location, and specifies the location mode.

Parameters:

retryContext - A RetryContext object that indicates the number of retries, last request's results, whether the next retry should happen in the primary or secondary location, and specifies the location mode.
secondaryNotFound - A boolean representing whether a request sent to the secondary location failed with 404 (Not Found)
retryInterval - Backoff Interval.

Returns:

A reference to the RetryInfo object that indicates whether the next retry will happen in the primary or secondary location, and specifies the location mode.

Applies to