Package com.microsoft.rest.retry
Class RetryStrategy
- java.lang.Object
-
- com.microsoft.rest.retry.RetryStrategy
-
- Direct Known Subclasses:
ExponentialBackoffRetryStrategy
public abstract class RetryStrategy extends Object
Represents a retry strategy that determines the number of retry attempts and the interval between retries.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CLIENT_RETRY_COUNTRepresents the default number of retry attempts.static booleanDEFAULT_FIRST_FAST_RETRYRepresents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.static intDEFAULT_RETRY_INTERVALRepresents the default interval between retries.
-
Constructor Summary
Constructors Modifier Constructor Description protectedRetryStrategy(String name, boolean firstFastRetry)Initializes a new instance of theRetryStrategyclass.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanisFastFirstRetry()Gets whether the first retry attempt will be made immediately.Stringname()Gets the name of the retry strategy.abstract booleanshouldRetry(int retryCount, okhttp3.Response response)Returns if a request should be retried based on the retry count, current response, and the current strategy.
-
-
-
Field Detail
-
DEFAULT_CLIENT_RETRY_COUNT
public static final int DEFAULT_CLIENT_RETRY_COUNT
Represents the default number of retry attempts.- See Also:
- Constant Field Values
-
DEFAULT_RETRY_INTERVAL
public static final int DEFAULT_RETRY_INTERVAL
Represents the default interval between retries.- See Also:
- Constant Field Values
-
DEFAULT_FIRST_FAST_RETRY
public static final boolean DEFAULT_FIRST_FAST_RETRY
Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RetryStrategy
protected RetryStrategy(String name, boolean firstFastRetry)
Initializes a new instance of theRetryStrategyclass.- Parameters:
name- The name of the retry strategy.firstFastRetry- true to immediately retry in the first attempt; otherwise, false.
-
-
Method Detail
-
shouldRetry
public abstract 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.- 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.
-
name
public String name()
Gets the name of the retry strategy.- Returns:
- the name of the retry strategy.
-
isFastFirstRetry
public boolean isFastFirstRetry()
Gets whether the first retry attempt will be made immediately.- Returns:
- true if the first retry attempt will be made immediately. false otherwise.
-
-