com.aliyuncs.kms.secretsmanager.client.utils.BackoffUtils Maven / Gradle / Ivy
package com.aliyuncs.kms.secretsmanager.client.utils;
import com.aliyuncs.exceptions.ClientException;
public class BackoffUtils {
/**
* KMS限流返回错误码
*/
private final static String REJECTED_THROTTLING = "Rejected.Throttling";
/**
* KMS服务不可用返回错误码
*/
private final static String SERVICE_UNAVAILABLE_TEMPORARY = "ServiceUnavailableTemporary";
/**
* KMS服务内部错误返回错误码
*/
private final static String INTERNAL_FAILURE = "InternalFailure";
private BackoffUtils() {
// do noting
}
/**
* 根据Client异常判断是否进行规避重试
*
* @param e 指定Client异常
* @return
*/
public static boolean judgeNeedBackoff(ClientException e) {
if (REJECTED_THROTTLING.equals(e.getErrCode()) || SERVICE_UNAVAILABLE_TEMPORARY.equals(e.getErrCode()) || INTERNAL_FAILURE.equals(e.getErrCode())) {
return true;
}
return false;
}
/**
* 根据Client异常判断是否进行容灾重试
*
* @param e 指定Client异常
* @return
*/
public static boolean judgeNeedRecoveryException(ClientException e) {
if (CacheClientConstant.SDK_READ_TIMEOUT.equals(e.getErrCode()) || CacheClientConstant.SDK_SERVER_UNREACHABLE.equals(e.getErrCode()) || judgeNeedBackoff(e)) {
return true;
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy