Search in sources :

Example 1 with DirectRetryingExecutor

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());
    }
}
Also used : DirectRetryingExecutor(com.google.api.gax.retrying.DirectRetryingExecutor) RetryAlgorithm(com.google.api.gax.retrying.RetryAlgorithm) ExponentialRetryAlgorithm(com.google.api.gax.retrying.ExponentialRetryAlgorithm) ExponentialRetryAlgorithm(com.google.api.gax.retrying.ExponentialRetryAlgorithm)

Aggregations

DirectRetryingExecutor (com.google.api.gax.retrying.DirectRetryingExecutor)1 ExponentialRetryAlgorithm (com.google.api.gax.retrying.ExponentialRetryAlgorithm)1 RetryAlgorithm (com.google.api.gax.retrying.RetryAlgorithm)1