public class CustomRetryStrategy extends Object implements RetryStrategy
RetryStrategy, 重试逻辑用于判断在发生异常时是否需要重试, 并给出本次重试的时间间隔.
DefaultRetryStrategy为TableStore SDK默认的重试逻辑.| 构造器和说明 |
|---|
CustomRetryStrategy() |
CustomRetryStrategy(long timeout,
TimeUnit unit) |
CustomRetryStrategy(long timeout,
TimeUnit unit,
boolean retryUnIdempotentWriteOperation) |
| 限定符和类型 | 方法和说明 |
|---|---|
RetryStrategy |
clone()
返回一个同类型且尚未重试的RetryStrategy对象。
|
int |
getRetries()
返回当前重试的次数
|
long |
nextPause(String action,
Exception ex)
若返回0,代表不可重试,否则返回本次重试的间隔时间。
|
boolean |
shouldRetry(String action,
Exception ex)
幂等操作:
本策略中,认为所有读相关的操作是幂等的,而所有写相关的操作会被认为是非幂等的。
|
public CustomRetryStrategy()
public CustomRetryStrategy(long timeout,
TimeUnit unit)
public CustomRetryStrategy(long timeout,
TimeUnit unit,
boolean retryUnIdempotentWriteOperation)
timeout - 重试超时时间unit - 超时时间单位retryUnIdempotentWriteOperation - 是否在可能非幂等的情况下重试写操作public RetryStrategy clone()
RetryStrategyclone 在接口中 RetryStrategyclone 在类中 Objectpublic int getRetries()
RetryStrategygetRetries 在接口中 RetryStrategypublic boolean shouldRetry(String action, Exception ex)
action - 操作名,比如"ListTable"、"GetRow"、"PutRow"等ex - 上次访问失败的错误信息、为ClientException或OTSExceptionpublic long nextPause(String action, Exception ex)
nextPause 在接口中 RetryStrategyaction - 操作名,比如"ListTable"、"GetRow"、"PutRow"等ex - 上次访问失败的错误信息、为ClientException或TableStoreExceptionCopyright © 2020. All Rights Reserved.