类 DefaultRetryPolicy
java.lang.Object
com.baidu.mochow.http.DefaultRetryPolicy
- 所有已实现的接口:
RetryPolicy
Retry policy that can be configured on a specific service client using
ClientConfiguration. This class is
immutable, therefore safe to be shared by multiple clients.- 另请参阅:
-
字段概要
从接口继承的字段 com.baidu.mochow.http.RetryPolicy
DEFAULT_MAX_DELAY_IN_MILLIS, DEFAULT_MAX_ERROR_RETRY, DEFAULT_RETRY_POLICY -
构造器概要
构造器构造器说明Constructs a new DefaultRetryPolicy.DefaultRetryPolicy(int maxErrorRetry, long maxDelayInMillis) Constructs a new retry policy. -
方法概要
修饰符和类型方法说明longgetDelayBeforeNextRetryInMillis(MochowClientException exception, int retriesAttempted) Returns the delay (in milliseconds) before next retry attempt.longReturns the maximum delay time (in milliseconds) before retrying a request.intReturns the maximum number of retry attempts.protected booleanshouldRetry(MochowClientException exception, int retriesAttempted) Returns whether a failed request should be retried according to the given request context.
-
构造器详细资料
-
DefaultRetryPolicy
public DefaultRetryPolicy()Constructs a new DefaultRetryPolicy. -
DefaultRetryPolicy
public DefaultRetryPolicy(int maxErrorRetry, long maxDelayInMillis) Constructs a new retry policy.- 参数:
maxErrorRetry- Maximum number of retry attempts for failed requests.maxDelayInMillis- Maximum delay time (in milliseconds) before next retry attempt.- 另请参阅:
-
-
方法详细资料
-
getMaxErrorRetry
public int getMaxErrorRetry()Returns the maximum number of retry attempts.- 指定者:
getMaxErrorRetry在接口中RetryPolicy- 返回:
- The maximum number of retry attempts.
-
getMaxDelayInMillis
public long getMaxDelayInMillis()Returns the maximum delay time (in milliseconds) before retrying a request.- 指定者:
getMaxDelayInMillis在接口中RetryPolicy- 返回:
- the maximum delay time (in milliseconds) before retrying a request.
-
getDelayBeforeNextRetryInMillis
Returns the delay (in milliseconds) before next retry attempt. A negative value indicates that no more retries should be made.- 指定者:
getDelayBeforeNextRetryInMillis在接口中RetryPolicy- 参数:
exception- the exception from the failed request, represented as an MochowClientException object.retriesAttempted- the number of times the current request has been attempted (not including the next attempt after the delay).- 返回:
- the delay (in milliseconds) before next retry attempt.A negative value indicates that no more retries should be made.
-
shouldRetry
Returns whether a failed request should be retried according to the given request context. In the following circumstances, the request will fail directly without consulting this method:- if it has already reached the max retry limit,
- if the request contains non-repeatable content,
- if any RuntimeException or Error is thrown when executing the request.
- 参数:
exception- the exception from the failed request, represented as a MochowClientException object.retriesAttempted- the number of times the current request has been attempted.- 返回:
- true if the failed request should be retried.
-