public static <V> V poll( Callable<V> callable, RetrySettings pollSettings, ResultRetryAlgorithm<V> resultPollAlgorithm, ApiClock clock) throws ExecutionException, InterruptedException { return run(callable, new ExponentialPollAlgorithm(pollSettings, clock), resultPollAlgorithm); }
static AwaitReplicationCallable create( UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> generateCallable, UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable, ClientContext clientContext, RetrySettings pollingSettings) { RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm = new RetryAlgorithm<>( new PollResultAlgorithm(), new ExponentialPollAlgorithm(pollingSettings, clientContext.getClock())); RetryingExecutor<CheckConsistencyResponse> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new AwaitReplicationCallable(generateCallable, checkCallable, retryingExecutor); }
public static <V> V poll( Callable<V> callable, RetrySettings pollSettings, ResultRetryAlgorithm<V> resultPollAlgorithm, ApiClock clock) throws ExecutionException, InterruptedException { return run(callable, new ExponentialPollAlgorithm(pollSettings, clock), resultPollAlgorithm); }
static AwaitReplicationCallable create( UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> generateCallable, UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable, ClientContext clientContext, RetrySettings pollingSettings) { RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm = new RetryAlgorithm<>( new PollResultAlgorithm(), new ExponentialPollAlgorithm(pollingSettings, clientContext.getClock())); RetryingExecutor<CheckConsistencyResponse> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new AwaitReplicationCallable(generateCallable, checkCallable, retryingExecutor); }
@Test public void testPollExceptionByPollAlgorithm() throws Exception { RetrySettings retrySettings = FAST_RETRY_SETTINGS .toBuilder() .setInitialRetryDelay(Duration.ofMillis(Integer.MAX_VALUE)) .setMaxRetryDelay(Duration.ofMillis(Integer.MAX_VALUE)) .build(); RetryAlgorithm<String> retryAlgorithm = new RetryAlgorithm<>( new TestResultRetryAlgorithm<String>(0, null), new ExponentialPollAlgorithm(retrySettings, NanoClock.getDefaultClock())); RetryingExecutorWithContext<String> executor = getExecutor(retryAlgorithm); FailingCallable callable = new FailingCallable(6, "FAILURE", tracer); RetryingFuture<String> future = executor.createFuture(callable, retryingContext); future.setAttemptFuture(executor.submit(future)); assertFutureFail(future, PollException.class); assertTrue(future.getAttemptSettings().getAttemptCount() < 4); verify(tracer, times(1)).attemptStarted(anyInt()); verify(tracer, times(1)).attemptPermanentFailure(any(PollException.class)); verifyNoMoreInteractions(tracer); }