public class ExponentialBackoff extends Object implements RetryStrategy
RetryStrategy that has a delay duration that exponentially
increases with each retry attempt until an upper bound is reached after which every retry attempt is delayed by the
provided max delay duration.HTTP_STATUS_TOO_MANY_REQUESTS| Constructor and Description |
|---|
ExponentialBackoff()
Creates an instance of
ExponentialBackoff with a maximum number of retry attempts configured by the
environment property Configuration.PROPERTY_AZURE_REQUEST_RETRY_COUNT, or three if it isn't configured or
is less than or equal to 0. |
ExponentialBackoff(int maxRetries,
Duration baseDelay,
Duration maxDelay)
Creates an instance of
ExponentialBackoff. |
| Modifier and Type | Method and Description |
|---|---|
Duration |
calculateRetryDelay(int retryAttempts)
Computes the delay between each retry.
|
int |
getMaxRetries()
Max number of retry attempts to be make.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitshouldRetry, shouldRetryExceptionpublic ExponentialBackoff()
ExponentialBackoff with a maximum number of retry attempts configured by the
environment property Configuration.PROPERTY_AZURE_REQUEST_RETRY_COUNT, or three if it isn't configured or
is less than or equal to 0. This strategy starts with a delay of 800 milliseconds and exponentially increases
with each additional retry attempt to a maximum of 8 seconds.public ExponentialBackoff(int maxRetries,
Duration baseDelay,
Duration maxDelay)
ExponentialBackoff.maxRetries - The max retry attempts that can be made.baseDelay - The base delay duration for retry.maxDelay - The max delay duration for retry.IllegalArgumentException - if maxRetries is less than 0 or baseDelay is less than or equal
to 0 or maxDelay is less than baseDelay.public int getMaxRetries()
RetryStrategygetMaxRetries in interface RetryStrategypublic Duration calculateRetryDelay(int retryAttempts)
RetryStrategycalculateRetryDelay in interface RetryStrategyretryAttempts - The number of retry attempts completed so far.Copyright © 2021 Microsoft Corporation. All rights reserved.