use of com.google.api.gax.retrying.DirectRetryingExecutor in project google-cloud-java by GoogleCloudPlatform.
the class RetryHelper method runWithRetries.
public static <V> V runWithRetries(Callable<V> callable, RetrySettings retrySettings, ExceptionHandler exceptionRetryAlgorithm, ApiClock clock) throws RetryHelperException {
try {
RetryAlgorithm retryAlgorithm = new RetryAlgorithm(exceptionRetryAlgorithm, new ExponentialRetryAlgorithm(retrySettings, clock));
RetryingExecutor<V> executor = new DirectRetryingExecutor<>(retryAlgorithm);
RetryingFuture<V> retryingFuture = executor.createFuture(callable);
executor.submit(retryingFuture);
return retryingFuture.get();
} catch (Exception e) {
throw new RetryHelperException(e.getCause());
}
}
Aggregations