/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwards(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, Executors.directExecutor()); }
/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwards(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, Executors.directExecutor()); }
/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwards(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, Executors.directExecutor()); }
/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwardsAsync(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, ForkJoinPool.commonPool()); }
/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwardsAsync(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, ForkJoinPool.commonPool()); }
/** * Run the given action after the completion of the given future. The given future can be * completed normally or exceptionally. In case of an exceptional completion the, the * action's exception will be added to the initial exception. * * @param future to wait for its completion * @param runnable action which is triggered after the future's completion * @return Future which is completed after the action has completed. This future can contain an exception, * if an error occurred in the given future or action. */ public static CompletableFuture<Void> runAfterwardsAsync(CompletableFuture<?> future, RunnableWithException runnable) { return runAfterwardsAsync(future, runnable, ForkJoinPool.commonPool()); }
@Override protected CompletableFuture<Void> shutDownInternal() { executionGraphCache.close(); final CompletableFuture<Void> shutdownFuture = super.shutDownInternal(); final File webUiDir = restConfiguration.getWebUiDir(); return FutureUtils.runAfterwardsAsync( shutdownFuture, () -> { Exception exception = null; try { log.info("Removing cache directory {}", webUiDir); FileUtils.deleteDirectory(webUiDir); } catch (Exception e) { exception = e; } try { leaderElectionService.stop(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (exception != null) { throw exception; } }); }
@Override protected CompletableFuture<Void> shutDownInternal() { executionGraphCache.close(); final CompletableFuture<Void> shutdownFuture = FutureUtils.runAfterwards( super.shutDownInternal(), () -> ExecutorUtils.gracefulShutdown(10, TimeUnit.SECONDS, executor)); final File webUiDir = restConfiguration.getWebUiDir(); return FutureUtils.runAfterwardsAsync( shutdownFuture, () -> { Exception exception = null; try { log.info("Removing cache directory {}", webUiDir); FileUtils.deleteDirectory(webUiDir); } catch (Exception e) { exception = e; } try { leaderElectionService.stop(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (exception != null) { throw exception; } }); }
@Override protected CompletableFuture<Void> shutDownInternal() { executionGraphCache.close(); final CompletableFuture<Void> shutdownFuture = FutureUtils.runAfterwards( super.shutDownInternal(), () -> ExecutorUtils.gracefulShutdown(10, TimeUnit.SECONDS, executor)); final File webUiDir = restConfiguration.getWebUiDir(); return FutureUtils.runAfterwardsAsync( shutdownFuture, () -> { Exception exception = null; try { log.info("Removing cache directory {}", webUiDir); FileUtils.deleteDirectory(webUiDir); } catch (Exception e) { exception = e; } try { leaderElectionService.stop(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (exception != null) { throw exception; } }); }