private <T> T callWithRetriesAndTimeout(Callable<T> callable, Optional<Integer> retryCount) throws Exception { RetryerBuilder<T> retryerBuilder = RetryerBuilder.<T>newBuilder() .withAttemptTimeLimiter(AttemptTimeLimiters.<T>fixedTimeLimit(configuration.getDockerClientTimeLimitSeconds(), TimeUnit.SECONDS, executor)); if (retryCount.isPresent()) { retryerBuilder.withStopStrategy(StopStrategies.stopAfterAttempt(retryCount.get())); } return retryerBuilder.build().call(callable); } }
.withAttemptTimeLimiter(AttemptTimeLimiters.fixedTimeLimit(getFetchOffsetTimeoutSec(), TimeUnit.SECONDS)) .retryIfExceptionOfType(Exception.class)