Refine search
@Override public void forceShutdown() { if (executor.isShutdown()) return; executor.shutdownNow(); }
private void shutdown() { if (!executorService.isShutdown()) { // Shutdown executorService executorService.shutdown(); } }
private void shutdownExecutorService(ExecutorService executorService) { if (!executorService.isShutdown()) { executorService.shutdown(); try { executorService.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { log.warn("ExecutorService did not shutdown normally."); executorService.shutdownNow(); } } }
@Override void close() { mappedBuffer.force(); try { checkpointFileHandle.close(); } catch (IOException e) { LOG.info("Error closing " + checkpointFile, e); } if (checkpointBackUpExecutor != null && !checkpointBackUpExecutor.isShutdown()) { checkpointBackUpExecutor.shutdown(); try { // Wait till the executor dies. while (!checkpointBackUpExecutor.awaitTermination(1, TimeUnit.SECONDS)) {} } catch (InterruptedException ex) { LOG.warn("Interrupted while waiting for checkpoint backup to " + "complete"); } } }
if (this.batchPool != null && !this.batchPool.isShutdown()) { this.batchPool.shutdown(); try { if (!this.batchPool.awaitTermination(10, TimeUnit.SECONDS)) { this.batchPool.shutdownNow(); this.batchPool.shutdownNow();
private void shutdownAsyncThreads() throws Exception { if (!asyncOperationsThreadPool.isShutdown()) { asyncOperationsThreadPool.shutdownNow(); } }
assertFalse(executor.isShutdown()); assertFalse(executor.isTerminated()); executor.shutdown(); assertTrue(executor.isShutdown()); try { executor.submit(doNothingRunnable); assertTrue(executor.awaitTermination(1, TimeUnit.SECONDS)); assertTrue(executor.awaitTermination(0, TimeUnit.SECONDS)); assertTrue(executor.isShutdown()); try { executor.submit(doNothingRunnable);
private void closeSessionMonitor() { if ( sessionMonitor != null && !sessionMonitor.isShutdown() ) { try { getLogChannel().logDebug( "Shutting down the Session Monitor." ); sessionMonitor.shutdown(); } finally { if ( !sessionMonitor.isTerminated() ) { sessionMonitor.shutdownNow(); } getLogChannel().logDebug( "Session Monitor shutdown." ); } } }
public void shutdown() { if (!executorService.isShutdown()) { LOG.info("shutting down async handler executor"); this.executorService.shutdownNow(); } }
/** * Tests background processing if an external executor service is provided. * * @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it */ @Test public void testInitializeExternalExec() throws ConcurrentException, InterruptedException { final ExecutorService exec = Executors.newCachedThreadPool(); try { initializer = new MultiBackgroundInitializer(exec); checkInitialize(); assertEquals("Wrong executor", exec, initializer .getActiveExecutor()); assertFalse("Executor was shutdown", exec.isShutdown()); } finally { exec.shutdown(); exec.awaitTermination(1, TimeUnit.SECONDS); } }
handlerService.shutdown(); if (!handlerService.isShutdown()) { handlerService.shutdownNow();
/** * Shutdown executors */ public void shutdown() { if (!bufferPadExecutors.isShutdown()) { bufferPadExecutors.shutdownNow(); } if (bufferPadSchedule != null && !bufferPadSchedule.isShutdown()) { bufferPadSchedule.shutdownNow(); } }
/** * Tests whether an external executor can be set using the * setExternalExecutor() method. */ @Test public void testSetExternalExecutor() { final ExecutorService exec = Executors.newCachedThreadPool(); try { final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(); init.setExternalExecutor(exec); assertEquals("Wrong executor service", exec, init .getExternalExecutor()); assertTrue("Wrong result of start()", init.start()); assertSame("Wrong active executor", exec, init.getActiveExecutor()); checkInitialize(init); assertFalse("Executor was shutdown", exec.isShutdown()); } finally { exec.shutdown(); } }
if (!executorService.isShutdown()) { boolean warned = false; StopWatch watch = new StopWatch(); executorService.shutdown(); warned = true; LOG.warn("Forcing shutdown of ExecutorService: {} due first await termination elapsed.", executorService); executorService.shutdownNow(); executorService.shutdownNow(); } finally { Thread.currentThread().interrupt(); executorService.shutdownNow(); } finally { Thread.currentThread().interrupt(); new Object[]{executorService, executorService.isShutdown(), executorService.isTerminated(), TimeUtils.printDuration(watch.taken())}); } else if (LOG.isDebugEnabled()) { LOG.debug("Shutdown of ExecutorService: {} is shutdown: {} and terminated: {} took: {}.", new Object[]{executorService, executorService.isShutdown(), executorService.isTerminated(), TimeUtils.printDuration(watch.taken())});
/** * Shutdown now the given executor service aggressively. * * @param executorService the executor service to shutdown now * @return list of tasks that never commenced execution * @see java.util.concurrent.ExecutorService#shutdownNow() */ public static List<Runnable> shutdownNow(ExecutorService executorService) { List<Runnable> answer = null; if (!executorService.isShutdown()) { LOG.debug("Forcing shutdown of ExecutorService: {}", executorService); answer = executorService.shutdownNow(); if (LOG.isTraceEnabled()) { LOG.trace("Shutdown of ExecutorService: {} is shutdown: {} and terminated: {}.", new Object[]{executorService, executorService.isShutdown(), executorService.isTerminated()}); } } return answer; }
/** * 在{@link Application#onTerminate}的时候销毁线程池 * */ public synchronized static void shutdown() { if (executor != null) { if (!executor.isShutdown()) { executor.shutdown(); } executor = null; } }
if (!executorService.isShutdown()) { executorService.shutdown(); final List<Runnable> cancelledTasks = executorService.shutdownNow(); for (Runnable cancelledTask : cancelledTasks) { if (cancelledTask instanceof Future) {
@Override public void stop() { // fix bug #968,对于pool与 workerPool.halt(); simpleParserStage.halt(); sinkStoreStage.halt(); try { parserExecutor.shutdownNow(); while (!parserExecutor.awaitTermination(1, TimeUnit.SECONDS)) { if (parserExecutor.isShutdown() || parserExecutor.isTerminated()) { break; } parserExecutor.shutdownNow(); } } catch (Throwable e) { // ignore } try { stageExecutor.shutdownNow(); while (!stageExecutor.awaitTermination(1, TimeUnit.SECONDS)) { if (stageExecutor.isShutdown() || stageExecutor.isTerminated()) { break; } stageExecutor.shutdownNow(); } } catch (Throwable e) { // ignore } super.stop(); }
public void run() { if (!executorService.isShutdown()) { System.err.println("shutdowHook shuts down executorService"); executorService.shutdown(); } } });
if (!executorService.isShutdown()) { executorService.shutdown(); final List<Runnable> cancelledTasks = executorService.shutdownNow(); for (Runnable cancelledTask : cancelledTasks) { if (cancelledTask instanceof Future) {