in src/main/java/com/aliyuncs/kms/secretsmanager/client/service/DefaultSecretManagerClientBuilder.java [128:180]
public GetSecretValueResponse getSecretValue(GetSecretValueRequest req) throws ClientException {
List<Future<GetSecretValueResponse>> futures = new ArrayList<>();
CountDownLatch count = null;
AtomicInteger finished = null;
for (int i = 0; i < regionInfos.size(); i++) {
if (i == 0) {
try {
return getSecretValue(regionInfos.get(i), req);
} catch (ClientException e) {
CommonLogger.getCommonLogger(CacheClientConstant.MODE_NAME).errorf("action:getSecretValue", e);
if (!BackoffUtils.judgeNeedRecoveryException(e)) {
throw e;
}
count = new CountDownLatch(1);
finished = new AtomicInteger(regionInfos.size());
}
}
GetSecretValueRequest request = new GetSecretValueRequest();
request.setSecretName(req.getSecretName());
request.setVersionStage(req.getVersionStage());
request.setFetchExtendedConfig(true);
request.setAcceptFormat(FormatType.XML);
Future<GetSecretValueResponse> future = pool.submit(new RetryGetSecretValueTask(request, regionInfos.get(i), count, finished));
futures.add(future);
}
GetSecretValueResponse getSecretValueResponse = null;
try {
count.await(CacheClientConstant.REQUEST_WAITING_TIME, TimeUnit.MILLISECONDS);
for (Future<GetSecretValueResponse> future : futures) {
try {
if (!future.isDone()) {
future.cancel(true);
} else {
getSecretValueResponse = future.get();
if (getSecretValueResponse != null) {
return getSecretValueResponse;
}
}
} catch (InterruptedException | ExecutionException e) {
CommonLogger.getCommonLogger(CacheClientConstant.MODE_NAME).errorf("action:asyncGetSecretValue", e);
}
}
} catch (InterruptedException e) {
CommonLogger.getCommonLogger(CacheClientConstant.MODE_NAME).errorf("action:retryGetSecretValueTask", e);
throw new ClientException(e);
} finally {
if (count.getCount() > 0) {
count.countDown();
}
}
throw new ClientException(CacheClientConstant.SDK_READ_TIMEOUT, String.format("refreshSecretTask fail with secretName[%s]", req.getSecretName()));
}