/** * Shuts the given {@link ExecutorService} down in a non-blocking fashion. The shut down will * be executed by a thread from the common fork-join pool. * * <p>The executor services will be shut down gracefully for the given timeout period. Afterwards * {@link ExecutorService#shutdownNow()} will be called. * * @param timeout before {@link ExecutorService#shutdownNow()} is called * @param unit time unit of the timeout * @param executorServices to shut down * @return Future which is completed once the {@link ExecutorService} are shut down */ public static CompletableFuture<Void> nonBlockingShutdown(long timeout, TimeUnit unit, ExecutorService... executorServices) { return CompletableFuture.supplyAsync( () -> { gracefulShutdown(timeout, unit, executorServices); return null; }); } }
final CompletableFuture<Void> executorShutdownFuture = ExecutorUtils.nonBlockingShutdown( gracePeriod.toMilliseconds(), TimeUnit.MILLISECONDS,
private CompletableFuture<Void> shutDownServices() { synchronized (lock) { Collection<CompletableFuture<Void>> terminationFutures = new ArrayList<>(3); Exception exception = null; try { blobCacheService.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } try { metricRegistry.shutdown(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (metricQueryServiceActorSystem != null) { terminationFutures.add(AkkaUtils.terminateActorSystem(metricQueryServiceActorSystem)); } try { highAvailabilityServices.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } terminationFutures.add(rpcService.stopService()); terminationFutures.add(ExecutorUtils.nonBlockingShutdown(timeout.toMilliseconds(), TimeUnit.MILLISECONDS, executor)); if (exception != null) { terminationFutures.add(FutureUtils.completedExceptionally(exception)); } return FutureUtils.completeAll(terminationFutures); } }
@Override public void close() throws Exception { super.close(); ExecutorUtils.gracefulShutdown(shutdownWaitTS, TimeUnit.MILLISECONDS, executorService); }
final CompletableFuture<Void> executorShutdownFuture = ExecutorUtils.nonBlockingShutdown( gracePeriod.toMilliseconds(), TimeUnit.MILLISECONDS,
@Override public void shutdown() { ExecutorUtils.gracefulShutdown(restClusterClientConfiguration.getRetryDelay(), TimeUnit.MILLISECONDS, retryExecutorService); this.restClient.shutdown(Time.seconds(5)); ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, this.executorService); try { webMonitorRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the webMonitorRetrievalService", e); } try { dispatcherRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the dispatcherLeaderRetriever", e); } try { // we only call this for legacy reasons to shutdown components that are started in the ClusterClient constructor super.shutdown(); } catch (Exception e) { log.error("An error occurred during the client shutdown.", e); } }
private CompletableFuture<Void> shutDownServices() { synchronized (lock) { Collection<CompletableFuture<Void>> terminationFutures = new ArrayList<>(3); Exception exception = null; try { blobCacheService.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } try { metricRegistry.shutdown(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } try { highAvailabilityServices.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } terminationFutures.add(rpcService.stopService()); terminationFutures.add(ExecutorUtils.nonBlockingShutdown(timeout.toMilliseconds(), TimeUnit.MILLISECONDS, executor)); if (exception != null) { terminationFutures.add(FutureUtils.completedExceptionally(exception)); } return FutureUtils.completeAll(terminationFutures); } }
ExecutorUtils.gracefulShutdown(10L, TimeUnit.MINUTES, queryExecutor);
final CompletableFuture<Void> executorShutdownFuture = ExecutorUtils.nonBlockingShutdown( gracePeriod.toMilliseconds(), TimeUnit.MILLISECONDS,
private void shutdownCluster( ClusterClient clusterClient, ScheduledExecutorService scheduledExecutorService, YarnApplicationStatusMonitor yarnApplicationStatusMonitor) { try { yarnApplicationStatusMonitor.close(); } catch (Exception e) { LOG.info("Could not properly close the Yarn application status monitor.", e); } clusterClient.shutDownCluster(); try { clusterClient.shutdown(); } catch (Exception e) { LOG.info("Could not properly shutdown cluster client.", e); } // shut down the scheduled executor service ExecutorUtils.gracefulShutdown( 1000L, TimeUnit.MILLISECONDS, scheduledExecutorService); deleteYarnPropertiesFile(); }
private CompletableFuture<Void> shutDownServices() { synchronized (lock) { Collection<CompletableFuture<Void>> terminationFutures = new ArrayList<>(3); Exception exception = null; try { blobCacheService.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } try { metricRegistry.shutdown(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (metricQueryServiceActorSystem != null) { terminationFutures.add(AkkaUtils.terminateActorSystem(metricQueryServiceActorSystem)); } try { highAvailabilityServices.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } terminationFutures.add(rpcService.stopService()); terminationFutures.add(ExecutorUtils.nonBlockingShutdown(timeout.toMilliseconds(), TimeUnit.MILLISECONDS, executor)); if (exception != null) { terminationFutures.add(FutureUtils.completedExceptionally(exception)); } return FutureUtils.completeAll(terminationFutures); } }
} finally { final long timeout = 10000L; ExecutorUtils.gracefulShutdown(timeout, TimeUnit.MILLISECONDS, executor);
ExecutorUtils.gracefulShutdown( AkkaUtils.getTimeout(config).toMillis(), TimeUnit.MILLISECONDS,
/** * Shuts the given {@link ExecutorService} down in a non-blocking fashion. The shut down will * be executed by a thread from the common fork-join pool. * * <p>The executor services will be shut down gracefully for the given timeout period. Afterwards * {@link ExecutorService#shutdownNow()} will be called. * * @param timeout before {@link ExecutorService#shutdownNow()} is called * @param unit time unit of the timeout * @param executorServices to shut down * @return Future which is completed once the {@link ExecutorService} are shut down */ public static CompletableFuture<Void> nonBlockingShutdown(long timeout, TimeUnit unit, ExecutorService... executorServices) { return CompletableFuture.supplyAsync( () -> { gracefulShutdown(timeout, unit, executorServices); return null; }); } }
/** * Shuts the given {@link ExecutorService} down in a non-blocking fashion. The shut down will * be executed by a thread from the common fork-join pool. * * <p>The executor services will be shut down gracefully for the given timeout period. Afterwards * {@link ExecutorService#shutdownNow()} will be called. * * @param timeout before {@link ExecutorService#shutdownNow()} is called * @param unit time unit of the timeout * @param executorServices to shut down * @return Future which is completed once the {@link ExecutorService} are shut down */ public static CompletableFuture<Void> nonBlockingShutdown(long timeout, TimeUnit unit, ExecutorService... executorServices) { return CompletableFuture.supplyAsync( () -> { gracefulShutdown(timeout, unit, executorServices); return null; }); } }
@Override public void shutdown() { ExecutorUtils.gracefulShutdown(restClusterClientConfiguration.getRetryDelay(), TimeUnit.MILLISECONDS, retryExecutorService); this.restClient.shutdown(Time.seconds(5)); ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, this.executorService); try { webMonitorRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the webMonitorRetrievalService", e); } try { dispatcherRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the dispatcherLeaderRetriever", e); } try { // we only call this for legacy reasons to shutdown components that are started in the ClusterClient constructor super.shutdown(); } catch (Exception e) { log.error("An error occurred during the client shutdown.", e); } }
@Override public void shutdown() { ExecutorUtils.gracefulShutdown(restClusterClientConfiguration.getRetryDelay(), TimeUnit.MILLISECONDS, retryExecutorService); this.restClient.shutdown(Time.seconds(5)); ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, this.executorService); try { webMonitorRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the webMonitorRetrievalService", e); } try { dispatcherRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the dispatcherLeaderRetriever", e); } try { // we only call this for legacy reasons to shutdown components that are started in the ClusterClient constructor super.shutdown(); } catch (Exception e) { log.error("An error occurred during the client shutdown.", e); } }
ExecutorUtils.gracefulShutdown(10L, TimeUnit.MINUTES, queryExecutor);
ExecutorUtils.gracefulShutdown(10L, TimeUnit.MINUTES, queryExecutor);
@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; } }); }