public class DefaultRetryStrategy extends Object implements RetryStrategy
RetryStrategy, 重试逻辑用于判断在发生异常时是否需要重试, 并给出本次重试的时间间隔.
DefaultRetryStrategy为TableStore SDK默认的重试逻辑.| Constructor and Description |
|---|
DefaultRetryStrategy() |
DefaultRetryStrategy(long timeout,
TimeUnit unit) |
| Modifier and Type | Method and Description |
|---|---|
RetryStrategy |
clone()
返回一个同类型且尚未重试的RetryStrategy对象。
|
int |
getRetries()
返回当前重试的次数
|
long |
nextPause(String action,
Exception ex)
得到发起第retries次重试前延迟的时间。SDK会在这一段时间之后发起第retries次重试。
若返回值小于等于0, 表示不重试.
|
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 in interface RetryStrategyclone in class Objectpublic int getRetries()
RetryStrategygetRetries in interface RetryStrategyprotected 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 in interface RetryStrategyaction - 操作名,比如"ListTable"、"GetRow"、"PutRow"等ex - 上次访问失败的错误信息、为ClientException或TableStoreExceptionCopyright © 2024. All Rights Reserved.