@Override public boolean isTerminated() { return delegate.isTerminated(); }
@Override public boolean isTerminated() { return service.isTerminated(); }
/** * {@inheritDoc} */ @Override public boolean isTerminated() { return delegate.isTerminated(); }
/** * {@inheritDoc} */ @Override public boolean isTerminated() { return delegate.isTerminated(); }
@Override public void run() { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { LOG.info("Shutting down Heartbeater thread pool."); heartbeatExecutorService.shutdown(); } } };
@Override public void run() { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { LOG.info("Shutting down Heartbeater thread pool."); heartbeatExecutorService.shutdown(); } } };
@Override protected void startUp() throws Exception { LOG.info("Starting the task executor"); if (this.taskExecutor.isShutdown() || this.taskExecutor.isTerminated()) { throw new IllegalStateException("Task thread pool executor is shutdown or terminated"); } if (this.forkExecutor.isShutdown() || this.forkExecutor.isTerminated()) { throw new IllegalStateException("Fork thread pool executor is shutdown or terminated"); } }
/** * Stop updater. */ public void stop() { if (running.compareAndSet(true, false)) { executor.shutdown(); while (!executor.isTerminated()) { try { executor.awaitTermination(100, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { return; } } LOG.debug("Webcam updater has been stopped"); } else { LOG.debug("Webcam updater is already stopped"); } }
/** * Stop this server. */ @Override public void stop() { service.shutdown(); while (!service.isTerminated()) { try { logger.warn("Waiting for ganglia service to stop"); service.awaitTermination(500, TimeUnit.MILLISECONDS); } catch (InterruptedException ex) { logger.warn("Interrupted while waiting" + " for ganglia monitor to shutdown", ex); service.shutdownNow(); } } addresses.clear(); }
private synchronized void initHeartbeatExecutorService() { synchronized (DbTxnManager.class) { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { return; } heartbeatExecutorService = Executors.newScheduledThreadPool( conf.getIntVar(HiveConf.ConfVars.HIVE_TXN_HEARTBEAT_THREADPOOL_SIZE), new ThreadFactory() { private final AtomicInteger threadCounter = new AtomicInteger(); @Override public Thread newThread(Runnable r) { return new HeartbeaterThread(r, "Heartbeater-" + threadCounter.getAndIncrement()); } }); ((ScheduledThreadPoolExecutor) heartbeatExecutorService).setRemoveOnCancelPolicy(true); } }
private synchronized void initHeartbeatExecutorService() { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { return; } heartbeatExecutorService = Executors.newScheduledThreadPool( conf.getIntVar(HiveConf.ConfVars.HIVE_TXN_HEARTBEAT_THREADPOOL_SIZE), new ThreadFactory() { private final AtomicInteger threadCounter = new AtomicInteger(); @Override public Thread newThread(Runnable r) { return new HeartbeaterThread(r, "Heartbeater-" + threadCounter.getAndIncrement()); } }); ((ScheduledThreadPoolExecutor) heartbeatExecutorService).setRemoveOnCancelPolicy(true); }
/** * Shutdown the task runner. */ public void shutdown() { LOG.info("Shutting down load monitor task runner."); _samplingScheduler.shutdown(); try { _samplingScheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); if (!_samplingScheduler.isTerminated()) { LOG.warn("The sampling scheduler failed to shutdown in " + _samplingIntervalMs + " ms."); } } catch (InterruptedException e) { LOG.warn("Interrupted while waiting for metric fetcher manager to shutdown."); } _metricFetcherManager.shutdown(); _sampleStore.close(); LOG.info("Load monitor task runner shutdown completed."); }
/** * Shutdown the metric fetcher manager. */ public void shutdown() { LOG.info("Shutting down anomaly detector."); _shutdown = true; _anomalies.addFirst(SHUTDOWN_ANOMALY); _detectorScheduler.shutdown(); try { _detectorScheduler.awaitTermination(_anomalyDetectionIntervalMs, TimeUnit.MILLISECONDS); if (!_detectorScheduler.isTerminated()) { LOG.warn("The sampling scheduler failed to shutdown in " + _anomalyDetectionIntervalMs + " ms."); } } catch (InterruptedException e) { LOG.warn("Interrupted while waiting for anomaly detector to shutdown."); } _brokerFailureDetector.shutdown(); LOG.info("Anomaly detector shutdown completed."); }
/** * Start this server, causing it to poll JMX at the configured frequency. */ @Override public void start() { try { socket = new DatagramSocket(); hostname = InetAddress.getLocalHost().getHostName(); } catch (SocketException ex) { logger.error("Could not create socket for metrics collection."); throw new FlumeException( "Could not create socket for metrics collection.", ex); } catch (Exception ex2) { logger.warn("Unknown error occured", ex2); } for (HostInfo host : hosts) { addresses.add(new InetSocketAddress( host.getHostName(), host.getPortNumber())); } collectorRunnable.server = this; if (service.isShutdown() || service.isTerminated()) { service = Executors.newSingleThreadScheduledExecutor(); } service.scheduleWithFixedDelay(collectorRunnable, 0, pollFrequency, TimeUnit.SECONDS); }
/** * Closes the log by terminating all threads and waiting for their termination. * * @throws com.thinkaurelius.titan.diskstorage.BackendException */ @Override public synchronized void close() throws BackendException { if (!isOpen) return; this.isOpen = false; if (readExecutor!=null) readExecutor.shutdown(); if (sendThread!=null) sendThread.close(CLOSE_DOWN_WAIT); if (readExecutor!=null) { try { readExecutor.awaitTermination(1,TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Could not terminate reader thread pool for KCVSLog "+name+" due to interruption"); } if (!readExecutor.isTerminated()) { readExecutor.shutdownNow(); log.error("Reader thread pool for KCVSLog "+name+" did not shut down in time - could not clean up or set read markers"); } else { for (MessagePuller puller : msgPullers) { puller.close(); } } } writeSetting(manager.senderId, MESSAGE_COUNTER_COLUMN, numMsgCounter.get()); store.close(); manager.closedLog(this); }
/** * Closes the log by terminating all threads and waiting for their termination. * * @throws org.janusgraph.diskstorage.BackendException */ @Override public synchronized void close() throws BackendException { if (!isOpen) return; this.isOpen = false; if (readExecutor!=null) readExecutor.shutdown(); if (sendThread!=null) sendThread.close(CLOSE_DOWN_WAIT); if (readExecutor!=null) { try { readExecutor.awaitTermination(1,TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Could not terminate reader thread pool for KCVSLog "+name+" due to interruption"); } if (!readExecutor.isTerminated()) { readExecutor.shutdownNow(); log.error("Reader thread pool for KCVSLog "+name+" did not shut down in time - could not clean up or set read markers"); } else { for (MessagePuller puller : msgPullers) { puller.close(); } } } writeSetting(manager.senderId, MESSAGE_COUNTER_COLUMN, numMsgCounter.get()); store.close(); manager.closedLog(this); }
@Test public void isTerminated() { boolean result = executor.isTerminated(); verify(delegate).isTerminated(); assertThat(result).isEqualTo(delegate.isTerminated()).isNotNull(); }
@Test public void isTerminated() { underTest.isTerminated(); verify(executorService).isTerminated(); }
@Test public void testShutdown() throws InterruptedException { AnomalyNotifier mockAnomalyNotifier = EasyMock.createNiceMock(AnomalyNotifier.class); BrokerFailureDetector mockBrokerFailureDetector = EasyMock.createNiceMock(BrokerFailureDetector.class); GoalViolationDetector mockGoalViolationDetector = EasyMock.createNiceMock(GoalViolationDetector.class); MetricAnomalyDetector mockMetricAnomalyDetector = EasyMock.createNiceMock(MetricAnomalyDetector.class); KafkaCruiseControl mockKafkaCruiseControl = EasyMock.createNiceMock(KafkaCruiseControl.class); ScheduledExecutorService detectorScheduler = Executors.newScheduledThreadPool(2, new KafkaCruiseControlThreadFactory("AnomalyDetector", false, null)); AnomalyDetector anomalyDetector = new AnomalyDetector(new LinkedBlockingDeque<>(), 3000L, mockKafkaCruiseControl, mockAnomalyNotifier, mockGoalViolationDetector, mockBrokerFailureDetector, mockMetricAnomalyDetector, detectorScheduler, EasyMock.mock(LoadMonitor.class)); anomalyDetector.shutdown(); Thread t = new Thread(anomalyDetector::shutdown); t.start(); t.join(30000L); assertTrue(detectorScheduler.isTerminated()); } }
protected void init() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.setRowFactory(param -> new JFXTreeTableRow<>()); this.getSelectionModel().selectedItemProperty().addListener((o, oldVal, newVal) -> { if (newVal != null && newVal.getValue() != null) { itemWasSelected = true; } }); this.predicate.addListener(observable -> filter(getPredicate())); this.sceneProperty().addListener(observable -> { if (getScene() == null) { threadPool.shutdownNow(); } else if (threadPool.isTerminated()) { threadPool = createThreadPool(); } }); this.rootProperty().addListener(observable -> { if (getRoot() != null) { setCurrentItemsCount(count(getRoot())); } if(!internalSetRoot) { originalRoot = getRoot(); reGroup(); } }); // compute the current items count setCurrentItemsCount(count(getRoot())); }