Class ExponentialBackoff
- java.lang.Object
-
- com.azure.android.core.http.policy.ExponentialBackoff
-
- All Implemented Interfaces:
RetryStrategy
public final class ExponentialBackoff extends java.lang.Object implements RetryStrategy
The retry strategy with full jitter backoff.
-
-
Constructor Summary
Constructors Constructor Description ExponentialBackoff()CreatesExponentialBackoffretry strategy with default settings.ExponentialBackoff(int maxRetries, org.threeten.bp.Duration baseDelay, org.threeten.bp.Duration maxDelay)CreatesExponentialBackoffretry strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.threeten.bp.DurationcalculateRetryDelay(HttpResponse response, java.lang.Throwable error, int retryAttempts)Determines the delay duration that should be waited before retrying.intgetMaxRetries()Get the maximum number of times to retry.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.azure.android.core.http.policy.RetryStrategy
shouldRetry
-
-
-
-
Constructor Detail
-
ExponentialBackoff
public ExponentialBackoff()
CreatesExponentialBackoffretry strategy with default settings.The default maximum number of times to retry is 3, the default base delay is 800 milliseconds and default maximum backoff delay before a retry is 8 seconds.
-
ExponentialBackoff
public ExponentialBackoff(int maxRetries, org.threeten.bp.Duration baseDelay, org.threeten.bp.Duration maxDelay)CreatesExponentialBackoffretry strategy.- Parameters:
maxRetries- The maximum number of times to retry.baseDelay- The delay used as the coefficient for backoffs, also the same delay will be used for the first backoff.maxDelay- The maximum backoff delay before a retry- Throws:
java.lang.IllegalArgumentException- if themaxRetriesis less than 0 or if thebaseDelayis zero or greater thanmaxDelay.
-
-
Method Detail
-
getMaxRetries
public int getMaxRetries()
Description copied from interface:RetryStrategyGet the maximum number of times to retry.- Specified by:
getMaxRetriesin interfaceRetryStrategy- Returns:
- The maximum number of times to retry.
-
calculateRetryDelay
public org.threeten.bp.Duration calculateRetryDelay(HttpResponse response, java.lang.Throwable error, int retryAttempts)
Description copied from interface:RetryStrategyDetermines the delay duration that should be waited before retrying.- Specified by:
calculateRetryDelayin interfaceRetryStrategy- Parameters:
response- The HTTP response.error- The pipeline exception, if any.retryAttempts- The number of retry attempts so far made.- Returns:
- The delay duration.
-
-