@Override public List<Runnable> shutdownNow() { return delegate.shutdownNow(); }
@LifecycleStop public void stop() { synchronized (lock) { if (!started) { return; } started = false; future.cancel(true); future = null; derivativesRef.set(new ConcurrentHashMap<>()); exec.shutdownNow(); exec = null; } }
future.cancel(false); future = null; exec.shutdownNow(); exec = null; clearTasks(); future.cancel(true); future = null; exec.shutdownNow(); exec = null; synchronized (taskLock) {
public void stop() { synchronized (lifecycleLock) { if (!lifecycleLock.canStop()) { throw new ISE("LookupCoordinatorManager can't stop."); } try { LOG.debug("Stopping"); if (backgroundManagerFuture != null && !backgroundManagerFuture.cancel(true)) { LOG.warn("Background lookup manager thread could not be cancelled"); } // signal the executorService to shut down ASAP, if this coordinator becomes leader again // then start() would ensure that this executorService is finished before starting a // new one. if (executorService != null) { executorService.shutdownNow(); } LOG.debug("Stopped"); } catch (Exception ex) { LOG.makeAlert(ex, "Got Exception while stop()").emit(); } finally { //so that subsequent start() would happen, even if stop() failed with exception lifecycleLock.exitStopAndReset(); } } }
@Override public void close() throws IOException { // This will cancel all the running tasks, with interruption - that means that all // queries submitted by this executor will be closed executor.shutdownNow(); }
@Override public void run() { executorService.shutdownNow(); } }
@Override public void run() { executorService.shutdownNow(); } }
@Override public void close() throws IOException { // This will cancel all the running tasks, with interruption - that means that all // queries submitted by this executor will be closed executor.shutdownNow(); }
@Override public void close() { if (closed.compareAndSet(false, true)) { synchronized (this.lock) { executor.shutdownNow(); watchers.forEach(Watcher::close); } } }
@Override public void close() { if (closed.compareAndSet(false, true)) { synchronized (this.lock) { executor.shutdownNow(); watchers.forEach(Watcher::close); } } }
private void shutdown() { final List<Runnable> remainingTasks = executorService.shutdownNow(); if (remainingTasks.size() > 0) { logger.info("Executor service shutting, {} pending tasks were cancelled.", remainingTasks.size()); } } }
@Override public synchronized void close() { if (this.closed) { return; } this.closed = true; if (!this.hasKeepAliveServiceStarted) { // hasKeepAliveServiceStarted hasn't started. return; } this.keepAliveFuture.cancel(true); this.deadlineFuture.cancel(true); this.keepAliveRequestObserver.onCompleted(); this.keepAliveResponseObserver.onCompleted(); this.scheduledExecutorService.shutdownNow(); final Throwable errResp = newClosedLeaseClientException(); this.keepAlives.forEach((k, v) -> v.onError(errResp)); this.keepAlives.clear(); }
@Override public synchronized void close() { if (this.closed) { return; } this.closed = true; if (!this.hasKeepAliveServiceStarted) { // hasKeepAliveServiceStarted hasn't started. return; } this.keepAliveFuture.cancel(true); this.deadlineFuture.cancel(true); this.keepAliveRequestObserver.onCompleted(); this.keepAliveResponseObserver.onCompleted(); this.scheduledExecutorService.shutdownNow(); final Throwable errResp = newClosedLeaseClientException(); this.keepAlives.forEach((k, v) -> v.onError(errResp)); this.keepAlives.clear(); }
@Override public final void shutdownNow(ShutdownEvent.ShutdownType shutdownType) { log.info("Service {} shutdown requested...", serviceName); if (shutdownNowInternal(shutdownType)) { log.debug("Service {} stopping executors...", serviceName); if (scheduledService.isPresent()) { scheduledService.get().shutdownNow(); } if (service.isPresent()) { service.get().shutdownNow(); } // Unsubscribe from events unsubscribe(); log.debug("Service {} stopped", serviceName); } else { log.info("Service {} shutdown aborted", serviceName); } }
@AfterMethod(alwaysRun=true) @Override public void tearDown() throws Exception { try { if (executor != null) executor.shutdownNow(); } finally { super.tearDown(); } }
@Test public void testShutdownOnClose() throws IOException { Injector i = Guice.createInjector(); Closer closer = i.getInstance(Closer.class); ListeningScheduledExecutorService executor = createMock(ListeningScheduledExecutorService.class); ExecutorServiceModule.shutdownOnClose(executor, closer); expect(executor.shutdownNow()).andReturn(ImmutableList.<Runnable> of()).atLeastOnce(); replay(executor); closer.close(); verify(executor); }
@Test public void testShutdownOnClose() throws IOException { Injector i = Guice.createInjector(); Closer closer = i.getInstance(Closer.class); ListeningScheduledExecutorService executor = createMock(ListeningScheduledExecutorService.class); ExecutorServiceModule.shutdownOnClose(executor, closer); expect(executor.shutdownNow()).andReturn(ImmutableList.<Runnable> of()).atLeastOnce(); replay(executor); closer.close(); verify(executor); }
future.cancel(false); future = null; exec.shutdownNow(); exec = null; clearTasks(); future.cancel(true); future = null; exec.shutdownNow(); exec = null; synchronized (taskLock) {
public void stop() { synchronized (lifecycleLock) { if (!lifecycleLock.canStop()) { throw new ISE("LookupCoordinatorManager can't stop."); } try { LOG.debug("Stopping"); if (backgroundManagerFuture != null && !backgroundManagerFuture.cancel(true)) { LOG.warn("Background lookup manager thread could not be cancelled"); } // signal the executorService to shut down ASAP, if this coordinator becomes leader again // then start() would ensure that this executorService is finished before starting a // new one. if (executorService != null) { executorService.shutdownNow(); } LOG.debug("Stopped"); } catch (Exception ex) { LOG.makeAlert(ex, "Got Exception while stop()").emit(); } finally { //so that subsequent start() would happen, even if stop() failed with exception lifecycleLock.exitStopAndReset(); } } }
public void stop() { synchronized (lifecycleLock) { if (!lifecycleLock.canStop()) { throw new ISE("LookupCoordinatorManager can't stop."); } try { LOG.debug("Stopping"); if (backgroundManagerFuture != null && !backgroundManagerFuture.cancel(true)) { LOG.warn("Background lookup manager thread could not be cancelled"); } // signal the executorService to shut down ASAP, if this coordinator becomes leader again // then start() would ensure that this executorService is finished before starting a // new one. if (executorService != null) { executorService.shutdownNow(); } LOG.debug("Stopped"); } catch (Exception ex) { LOG.makeAlert(ex, "Got Exception while stop()").emit(); } finally { //so that subsequent start() would happen, even if stop() failed with exception lifecycleLock.exitStopAndReset(); } } }