类 DefaultRetryPolicy
- java.lang.Object
-
- com.baidubce.http.DefaultRetryPolicy
-
- 所有已实现的接口:
RetryPolicy
public class DefaultRetryPolicy extends Object implements RetryPolicy
Retry policy that can be configured on a specific service client usingBceClientConfiguration. This class is immutable, therefore safe to be shared by multiple clients.- 另请参阅:
BceClientConfiguration
-
-
字段概要
-
从接口继承的字段 com.baidubce.http.RetryPolicy
DEFAULT_MAX_DELAY_IN_MILLIS, DEFAULT_MAX_ERROR_RETRY, DEFAULT_RETRY_POLICY
-
-
构造器概要
构造器 构造器 说明 DefaultRetryPolicy()Constructs a new DefaultRetryPolicy.DefaultRetryPolicy(int maxErrorRetry, long maxDelayInMillis)Constructs a new retry policy.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 longgetDelayBeforeNextRetryInMillis(BceClientException exception, int retriesAttempted)Returns the delay (in milliseconds) before next retry attempt.longgetMaxDelayInMillis()Returns the maximum delay time (in milliseconds) before retrying a request.intgetMaxErrorRetry()Returns the maximum number of retry attempts.protected booleanshouldRetry(BceClientException 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.- 另请参阅:
BceClientConfiguration
-
-
方法详细资料
-
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
public long getDelayBeforeNextRetryInMillis(BceClientException exception, int retriesAttempted)
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 BceClientException 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
protected boolean shouldRetry(BceClientException exception, int retriesAttempted)
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 BceClientException object.retriesAttempted- the number of times the current request has been attempted.- 返回:
- true if the failed request should be retried.
-
-