Package com.microsoft.rest.retry
Class ExponentialBackoffRetryStrategy
- java.lang.Object
-
- com.microsoft.rest.retry.RetryStrategy
-
- com.microsoft.rest.retry.ExponentialBackoffRetryStrategy
-
public final class ExponentialBackoffRetryStrategy extends RetryStrategy
A retry strategy with backoff parameters for calculating the exponential delay between retries.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CLIENT_BACKOFFRepresents the default amount of time used when calculating a random delta in the exponential delay between retries.static intDEFAULT_MAX_BACKOFFRepresents the default maximum amount of time used when calculating the exponential delay between retries.static intDEFAULT_MIN_BACKOFFRepresents the default minimum amount of time used when calculating the exponential delay between retries.-
Fields inherited from class com.microsoft.rest.retry.RetryStrategy
DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_FIRST_FAST_RETRY, DEFAULT_RETRY_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description ExponentialBackoffRetryStrategy()Initializes a new instance of theExponentialBackoffRetryStrategyclass.ExponentialBackoffRetryStrategy(int retryCount, int minBackoff, int maxBackoff, int deltaBackoff)Initializes a new instance of theExponentialBackoffRetryStrategyclass.ExponentialBackoffRetryStrategy(String name, int retryCount, int minBackoff, int maxBackoff, int deltaBackoff, boolean firstFastRetry)Initializes a new instance of theExponentialBackoffRetryStrategyclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanshouldRetry(int retryCount, okhttp3.Response response)Returns if a request should be retried based on the retry count, current response, and the current strategy.-
Methods inherited from class com.microsoft.rest.retry.RetryStrategy
isFastFirstRetry, name
-
-
-
-
Field Detail
-
DEFAULT_CLIENT_BACKOFF
public static final int DEFAULT_CLIENT_BACKOFF
Represents the default amount of time used when calculating a random delta in the exponential delay between retries.- See Also:
- Constant Field Values
-
DEFAULT_MAX_BACKOFF
public static final int DEFAULT_MAX_BACKOFF
Represents the default maximum amount of time used when calculating the exponential delay between retries.- See Also:
- Constant Field Values
-
DEFAULT_MIN_BACKOFF
public static final int DEFAULT_MIN_BACKOFF
Represents the default minimum amount of time used when calculating the exponential delay between retries.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExponentialBackoffRetryStrategy
public ExponentialBackoffRetryStrategy()
Initializes a new instance of theExponentialBackoffRetryStrategyclass.
-
ExponentialBackoffRetryStrategy
public ExponentialBackoffRetryStrategy(int retryCount, int minBackoff, int maxBackoff, int deltaBackoff)Initializes a new instance of theExponentialBackoffRetryStrategyclass.- Parameters:
retryCount- The maximum number of retry attempts.minBackoff- The minimum backoff time.maxBackoff- The maximum backoff time.deltaBackoff- The value that will be used to calculate a random delta in the exponential delay between retries.
-
ExponentialBackoffRetryStrategy
public ExponentialBackoffRetryStrategy(String name, int retryCount, int minBackoff, int maxBackoff, int deltaBackoff, boolean firstFastRetry)
Initializes a new instance of theExponentialBackoffRetryStrategyclass.- Parameters:
name- The name of the retry strategy.retryCount- The maximum number of retry attempts.minBackoff- The minimum backoff time.maxBackoff- The maximum backoff time.deltaBackoff- The value that will be used to calculate a random delta in the exponential delay between retries.firstFastRetry- true to immediately retry in the first attempt; otherwise, false. The subsequent retries will remain subject to the configured retry interval.
-
-
Method Detail
-
shouldRetry
public boolean shouldRetry(int retryCount, okhttp3.Response response)Returns if a request should be retried based on the retry count, current response, and the current strategy.- Specified by:
shouldRetryin classRetryStrategy- Parameters:
retryCount- The current retry attempt count.response- The exception that caused the retry conditions to occur.- Returns:
- true if the request should be retried; false otherwise.
-
-