public class DefaultRetryStrategy extends Object implements RetryStrategy
RetryStrategy, 重试逻辑用于判断在发生异常时是否需要重试, 并给出本次重试的时间间隔.
DefaultRetryStrategy为TableStore SDK默认的重试逻辑.| 构造器和说明 |
|---|
DefaultRetryStrategy() |
DefaultRetryStrategy(long timeout,
TimeUnit unit) |
| 限定符和类型 | 方法和说明 |
|---|---|
RetryStrategy |
clone()
返回一个同类型且尚未重试的RetryStrategy对象。
|
int |
getRetries()
返回当前重试的次数
|
protected boolean |
isIdempotent(String action) |
long |
nextPause(String action,
Exception ex)
得到发起第retries次重试前延迟的时间。
|
protected boolean |
retryNotMatterActions(String errorCode,
String errorMessage) |
boolean |
shouldRetry(String action,
Exception ex)
SDK提供的默认重试策略,规则为:
1.
|
protected boolean |
shouldRetryWithOTSException(String action,
boolean isIdempotent,
String errorCode,
String errorMessage,
int httpStatus) |
public DefaultRetryStrategy()
public DefaultRetryStrategy(long timeout,
TimeUnit unit)
public RetryStrategy clone()
RetryStrategyclone 在接口中 RetryStrategyclone 在类中 Objectpublic int getRetries()
RetryStrategygetRetries 在接口中 RetryStrategyprotected boolean isIdempotent(String action)
protected boolean retryNotMatterActions(String errorCode, String errorMessage)
protected boolean shouldRetryWithOTSException(String action, boolean isIdempotent, String errorCode, String errorMessage, int httpStatus)
public boolean shouldRetry(String action, Exception ex)
action - 操作名,比如"ListTable"、"GetRow"、"PutRow"等ex - 上次访问失败的错误信息、为ClientException或OTSExceptionpublic long nextPause(String action, Exception ex)
RetryStrategynextPause 在接口中 RetryStrategyaction - 操作名,比如"ListTable"、"GetRow"、"PutRow"等ex - 上次访问失败的错误信息、为ClientException或TableStoreExceptionCopyright © 2022. All Rights Reserved.