Package com.azure.core.http.policy
Class FixedDelay
java.lang.Object
com.azure.core.http.policy.FixedDelay
- All Implemented Interfaces:
RetryStrategy
A fixed-delay implementation of
RetryStrategy that has a fixed delay duration between each retry attempt.-
Field Summary
Fields inherited from interface com.azure.core.http.policy.RetryStrategy
HTTP_STATUS_TOO_MANY_REQUESTS -
Constructor Summary
ConstructorsConstructorDescriptionFixedDelay(int maxRetries, Duration delay) Creates an instance ofFixedDelay.FixedDelay(FixedDelayOptions fixedDelayOptions) Creates an instance ofFixedDelay. -
Method Summary
Modifier and TypeMethodDescriptioncalculateRetryDelay(int retryAttempts) Computes the delay between each retry.intMax number of retry attempts to be make.booleanshouldRetryCondition(RequestRetryCondition requestRetryCondition) This method is consulted to determine if a retry attempt should be made for the givenRequestRetryCondition.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.core.http.policy.RetryStrategy
shouldRetry, shouldRetryException
-
Constructor Details
-
FixedDelay
Creates an instance ofFixedDelay.- Parameters:
maxRetries- The max number of retry attempts that can be made.delay- The fixed delay duration between retry attempts.- Throws:
IllegalArgumentException- IfmaxRetriesis negative.NullPointerException- Ifdelayisnull.
-
FixedDelay
Creates an instance ofFixedDelay.- Parameters:
fixedDelayOptions- TheFixedDelayOptions.
-
-
Method Details
-
getMaxRetries
public int getMaxRetries()Description copied from interface:RetryStrategyMax number of retry attempts to be make.- Specified by:
getMaxRetriesin interfaceRetryStrategy- Returns:
- The max number of retry attempts.
-
calculateRetryDelay
Description copied from interface:RetryStrategyComputes the delay between each retry.- Specified by:
calculateRetryDelayin interfaceRetryStrategy- Parameters:
retryAttempts- The number of retry attempts completed so far.- Returns:
- The delay duration before the next retry.
-
shouldRetryCondition
Description copied from interface:RetryStrategyThis method is consulted to determine if a retry attempt should be made for the givenRequestRetryCondition.By default, if the
RequestRetryConditioncontains a non-nullHttpResponse, then theRetryStrategy.shouldRetry(HttpResponse)method is called, otherwise theRetryStrategy.shouldRetryException(Throwable)method is called.- Specified by:
shouldRetryConditionin interfaceRetryStrategy- Parameters:
requestRetryCondition- TheRequestRetryConditioncontaining information that can be used to determine if the request should be retried.- Returns:
- Whether a retry should be attempted.
-