private ApiFuture<Void> pollToken(CheckConsistencyRequest request, ApiCallContext context) { AttemptCallable<CheckConsistencyRequest, CheckConsistencyResponse> attemptCallable = new AttemptCallable<>(checkCallable, request, context); RetryingFuture<CheckConsistencyResponse> retryingFuture = executor.createFuture(attemptCallable); attemptCallable.setExternalFuture(retryingFuture); attemptCallable.call(); return ApiFutures.transform( retryingFuture, new ApiFunction<CheckConsistencyResponse, Void>() { @Override public Void apply(CheckConsistencyResponse input) { return null; } }, MoreExecutors.directExecutor()); }
private static <V> V run( Callable<V> callable, TimedRetryAlgorithm timedAlgorithm, ResultRetryAlgorithm<V> resultAlgorithm) throws ExecutionException, InterruptedException { RetryAlgorithm<V> retryAlgorithm = new RetryAlgorithm<>(resultAlgorithm, timedAlgorithm); RetryingExecutor<V> executor = new DirectRetryingExecutor<>(retryAlgorithm); RetryingFuture<V> retryingFuture = executor.createFuture(callable); executor.submit(retryingFuture); return retryingFuture.get(); }
@Override public RetryingFuture<Void> futureCall(MutateRowsRequest request, ApiCallContext inputContext) { ApiCallContext context = callContextPrototype.nullToSelf(inputContext); MutateRowsAttemptCallable retryCallable = new MutateRowsAttemptCallable(callable.all(), request, context, retryCodes); RetryingFuture<Void> retryingFuture = executor.createFuture(retryCallable); retryCallable.setExternalFuture(retryingFuture); retryCallable.call(); return retryingFuture; }
private ApiFuture<Void> pollToken(CheckConsistencyRequest request, ApiCallContext context) { AttemptCallable<CheckConsistencyRequest, CheckConsistencyResponse> attemptCallable = new AttemptCallable<>(checkCallable, request, context); RetryingFuture<CheckConsistencyResponse> retryingFuture = executor.createFuture(attemptCallable); attemptCallable.setExternalFuture(retryingFuture); attemptCallable.call(); return ApiFutures.transform( retryingFuture, new ApiFunction<CheckConsistencyResponse, Void>() { @Override public Void apply(CheckConsistencyResponse input) { return null; } }, MoreExecutors.directExecutor()); }
private static <V> V run( Callable<V> callable, TimedRetryAlgorithm timedAlgorithm, ResultRetryAlgorithm<V> resultAlgorithm) throws ExecutionException, InterruptedException { RetryAlgorithm<V> retryAlgorithm = new RetryAlgorithm<>(resultAlgorithm, timedAlgorithm); RetryingExecutor<V> executor = new DirectRetryingExecutor<>(retryAlgorithm); RetryingFuture<V> retryingFuture = executor.createFuture(callable); executor.submit(retryingFuture); return retryingFuture.get(); }
@Override public RetryingFuture<Void> futureCall(MutateRowsRequest request, ApiCallContext inputContext) { ApiCallContext context = callContextPrototype.nullToSelf(inputContext); MutateRowsAttemptCallable retryCallable = new MutateRowsAttemptCallable(callable.all(), request, context, retryCodes); RetryingFuture<Void> retryingFuture = executor.createFuture(retryCallable); retryCallable.setExternalFuture(retryingFuture); retryCallable.call(); return retryingFuture; }