@Test public void backsOffExponentially() throws Exception { mockRetries(11); when(task.run()).thenThrow(new TransactionFailedRetriableException("")); List<Integer> rawBlockTimes = ImmutableList.of( 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 60000, 60000); List<Integer> randomizedBlockTimes = Lists.transform(rawBlockTimes, x -> x - 1); long expectedBlockDuration = randomizedBlockTimes.stream().mapToInt(x -> x).sum(); assertThatExceptionOfType(TransactionFailedRetriableException.class).isThrownBy(this::runExponential); assertThat(blockStrategy.totalBlockedTime).isEqualTo(expectedBlockDuration); }
@JsonCreator private static TransactionRetryStrategy of(Strategies strategy) { return strategy.strategy; }
TransactionRetryStrategy { @JsonCreator private static TransactionRetryStrategy of(Strategies strategy) { return strategy.strategy; } }
TransactionRetryStrategy { @JsonCreator private static TransactionRetryStrategy of(Strategies strategy) { return strategy.strategy; } private  TransactionRetryStrategy(WaitStrategy waitStrategy, BlockStrategy blockStrategy); }
TransactionRetryStrategy { @JsonCreator private static TransactionRetryStrategy of(Strategies strategy) { return strategy.strategy; } private  TransactionRetryStrategy(WaitStrategy waitStrategy, BlockStrategy blockStrategy); T runWithRetry(IntPredicate shouldStopRetrying, Retryable<T, E> task); }
TransactionRetryStrategy { @JsonCreator private static TransactionRetryStrategy of(Strategies strategy) { return strategy.strategy; } private  TransactionRetryStrategy(WaitStrategy waitStrategy, BlockStrategy blockStrategy); T runWithRetry(IntPredicate shouldStopRetrying, Retryable<T, E> task);  }