/** * Shutdown an {@link ExecutorService} gradually, first disabling new task submissions and * later cancelling existing tasks. * * <p> * This method calls {@link #shutdownExecutorService(ExecutorService, Optional, long, TimeUnit)} * with default timeout time {@link #EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT} and time unit * {@link #EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT_TIMEUNIT}. * </p> * * @param executorService the {@link ExecutorService} to shutdown * @param logger an {@link Optional} wrapping a {@link Logger} to be used during shutdown */ public static void shutdownExecutorService(ExecutorService executorService, Optional<Logger> logger) { shutdownExecutorService(executorService, logger, EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT, EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT_TIMEUNIT); }
@Override public void close() throws IOException { ExecutorsUtils.shutdownExecutorService(_execService, Optional.of(_log), 5, TimeUnit.SECONDS); }
@Override protected void shutDown() throws Exception { ExecutorsUtils.shutdownExecutorService(this.fetchJobSpecExecutor, Optional.of(LOGGER)); } }
/** * Closes this {@link TaskScheduler}, ensuring that new tasks cannot be created * and cancelling existing tasks. * * @throws IOException if an I/O error occurs */ @Override final void closeImpl() throws IOException { ExecutorsUtils.shutdownExecutorService(this.executorService, Optional.of(LOGGER)); }
@Override public void close() throws IOException { ExecutorsUtils.shutdownExecutorService(this.exeSvc, Optional.of(LOG)); }
@Override protected void shutDown() throws Exception { LOG.info("Stopping the task executor"); try { ExecutorsUtils.shutdownExecutorService(this.taskExecutor, Optional.of(LOG)); } finally { ExecutorsUtils.shutdownExecutorService(this.forkExecutor, Optional.of(LOG)); } }
public void closeNow() { ExecutorsUtils.shutdownExecutorService(this.exeSvc, Optional.of(LOG), 0, TimeUnit.NANOSECONDS); }
/** * {@inheritDoc} */ @Override public void cleanup() throws IOException { this.client.close(); ExecutorsUtils.shutdownExecutorService(this.singleThreadPool, Optional.of(log)); }
@Override public void close() throws IOException { try { ExecutorsUtils.shutdownExecutorService(this.hivePolicyExecutor, Optional.of(log)); } finally { this.closer.close(); } }
@Override protected void shutDown() throws Exception { this.logger.info("Stopping the task state tracker"); ExecutorsUtils.shutdownExecutorService(this.taskMetricsUpdaterExecutor, Optional.of(this.logger)); }
private void shutdownExecutors() { LOG.info("Shutting down Executors"); ExecutorsUtils.shutdownExecutorService(this.jobExecutor, Optional.of(LOG)); }
@Override public void close() throws IOException { try { this.closer.close(); } finally { if (this.writerMetricsUpdater.isPresent()) { ExecutorsUtils.shutdownExecutorService(this.writerMetricsUpdater.get(), Optional.of(log)); } } }
@Override protected void shutDown() throws Exception { LOGGER.info("Stopping the " + YarnAppSecurityManager.class.getSimpleName()); if (this.scheduledTokenRenewTask.isPresent()) { this.scheduledTokenRenewTask.get().cancel(true); } ExecutorsUtils.shutdownExecutorService(this.loginExecutor, Optional.of(LOGGER)); ExecutorsUtils.shutdownExecutorService(this.tokenRenewExecutor, Optional.of(LOGGER)); }
@Override public void close() throws IOException { log.info("Close called"); this.closer.close(); if (this.retryThreadPool.isPresent()) { // Shutdown the retry thread pool immediately, no use waiting for in-progress retries ExecutorsUtils.shutdownExecutorService(this.retryThreadPool.get(), Optional.of(log), 1, TimeUnit.MILLISECONDS); } log.info("Successfully done closing"); }
@Override public void stopImpl() { if (this.scheduledTask.isPresent()) { this.scheduledTask.get().cancel(false); } this.scheduledTask = Optional.absent(); ExecutorsUtils.shutdownExecutorService(this.executor, Optional.of(log), 10, TimeUnit.SECONDS); // Report metrics one last time - this ensures any metrics values updated between intervals are reported report(true); }
@Override public void close() throws IOException { try { waitForTasks(); } finally { ExecutorsUtils.shutdownExecutorService(this.executor, Optional.of(LOGGER)); } } }
@Override public void close() throws IOException { try { if (this.finishCleanSignal.isPresent()) { this.finishCleanSignal.get().await(); } if (!this.throwables.isEmpty()) { for (Throwable t : this.throwables) { LOG.error("Failed clean due to ", t); } throw new RuntimeException("Clean failed for one or more datasets"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("Not all datasets finish cleanning", e); } finally { ExecutorsUtils.shutdownExecutorService(this.service, Optional.of(LOG)); this.closer.close(); } }
@Override public void shutDown() { if (this.consumer != null) { this.consumer.shutdown(); } if (this.executor != null) { ExecutorsUtils.shutdownExecutorService(this.executor, Optional.of(log), 5000, TimeUnit.MILLISECONDS); } try { this.shutdownMetrics(); } catch (IOException ioe) { log.warn("Failed to shutdown metrics for " + this.getClass().getSimpleName()); } }
@Override protected void shutDown() throws Exception { if (this.specConsumer instanceof Service) { ((Service) this.specConsumer).stopAsync().awaitTerminated(this.stopTimeoutSeconds, TimeUnit.SECONDS); } ExecutorsUtils.shutdownExecutorService(this.fetchJobSpecExecutor, Optional.of(LOGGER)); } }
@Override protected void shutDown() throws Exception { LOG.info("Stopping the job scheduler"); closer.close(); cancelRequested = true; List<JobExecutionContext> currentExecutions = this.scheduler.getScheduler().getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentExecutions) { try { this.scheduler.getScheduler().interrupt(jobExecutionContext.getFireInstanceId()); } catch (UnableToInterruptJobException e) { LOG.error("Failed to cancel job " + jobExecutionContext.getJobDetail().getKey(), e); } } ExecutorsUtils.shutdownExecutorService(this.jobExecutor, Optional.of(LOG)); }