/** * Executes a {@link Runnable}, retrying if it throws something retryable. * * @param runnable the runnable to run * @param retryStrategy the retry strategy to use if the callable fails in a retryable way * @param isRetryable predicate to determine whether the callable failure is retryable or not * @param <T> the type of throwable * @throws InterruptedException if the call was interrupted between retries. The last Throwable that triggered the * retry will be added as a suppressed exception. * @throws T if the callable failed in a way that is not retryable, or the retries were exhausted. * If retries were exhausted, a {@link RetriesExhaustedException} will be added as a suppressed exception. */ public static <T extends Throwable> void runWithInterruptibleRetries(Runnable<T> runnable, RetryStrategy retryStrategy, Predicate<Throwable> isRetryable) throws T, InterruptedException { callWithInterruptibleRetries((Callable<Void, T>) () -> { runnable.run(); return null; }, retryStrategy, isRetryable); }
/** * Executes a {@link Runnable}, retrying if it throws something retryable. * * @param runnable the runnable to run * @param retryStrategy the retry strategy to use if the callable fails in a retryable way * @param isRetryable predicate to determine whether the callable failure is retryable or not * @param <T> the type of throwable * @throws InterruptedException if the call was interrupted between retries. The last Throwable that triggered the * retry will be added as a suppressed exception. * @throws T if the callable failed in a way that is not retryable, or the retries were exhausted. * If retries were exhausted, a {@link RetriesExhaustedException} will be added as a suppressed exception. */ public static <T extends Throwable> void runWithInterruptibleRetries(Runnable<T> runnable, RetryStrategy retryStrategy, Predicate<Throwable> isRetryable) throws T, InterruptedException { callWithInterruptibleRetries((Callable<Void, T>) () -> { runnable.run(); return null; }, retryStrategy, isRetryable); }
LOG.debug("Executing {} subtask {} for program run {}.", taskInfo.getProvisioningOp().getType(), state, programRunId); taskInfoOptional = Retries.callWithInterruptibleRetries(() -> subtask.execute(taskInfo), retryStrategy, t -> t instanceof RetryableProvisionException); LOG.debug("Completed {} subtask {} for program run {}.",
LOG.debug("Executing {} subtask {} for program run {}.", taskInfo.getProvisioningOp().getType(), state, programRunId); taskInfoOptional = Retries.callWithInterruptibleRetries(() -> subtask.execute(taskInfo), retryStrategy, t -> t instanceof RetryableProvisionException); LOG.debug("Completed {} subtask {} for program run {}.",
try { return Retries.callWithInterruptibleRetries(() -> Transactionals.execute(transactional, dsContext -> { ProvisionerDataset dataset = ProvisionerDataset.get(dsContext, datasetFramework); ProvisioningTaskInfo currentState = dataset.getTaskInfo(taskKey);
try { return Retries.callWithInterruptibleRetries(() -> Transactionals.execute(transactional, dsContext -> { ProvisionerDataset dataset = ProvisionerDataset.get(dsContext, datasetFramework); ProvisioningTaskInfo currentState = dataset.getTaskInfo(taskKey);