本文整理了Java中java.util.concurrent.ScheduledExecutorService.isTerminated()
方法的一些代码示例,展示了ScheduledExecutorService.isTerminated()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledExecutorService.isTerminated()
方法的具体详情如下:
包路径:java.util.concurrent.ScheduledExecutorService
类名称:ScheduledExecutorService
方法名:isTerminated
暂无
代码示例来源:origin: SonarSource/sonarqube
@Override
public boolean isTerminated() {
return delegate.isTerminated();
}
代码示例来源:origin: runelite/runelite
@Override
public boolean isTerminated()
{
return service.isTerminated();
}
代码示例来源:origin: io.dropwizard.metrics/metrics-core
/**
* {@inheritDoc}
*/
@Override
public boolean isTerminated() {
return delegate.isTerminated();
}
代码示例来源:origin: networknt/light-4j
/**
* {@inheritDoc}
*/
@Override
public boolean isTerminated() {
return delegate.isTerminated();
}
代码示例来源:origin: apache/hive
@Override
public void run() {
if (heartbeatExecutorService != null
&& !heartbeatExecutorService.isShutdown()
&& !heartbeatExecutorService.isTerminated()) {
LOG.info("Shutting down Heartbeater thread pool.");
heartbeatExecutorService.shutdown();
}
}
};
代码示例来源:origin: apache/drill
@Override
public void run() {
if (heartbeatExecutorService != null
&& !heartbeatExecutorService.isShutdown()
&& !heartbeatExecutorService.isTerminated()) {
LOG.info("Shutting down Heartbeater thread pool.");
heartbeatExecutorService.shutdown();
}
}
};
代码示例来源:origin: apache/incubator-gobblin
@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");
}
}
代码示例来源:origin: sarxos/webcam-capture
/**
* 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");
}
}
代码示例来源:origin: apache/flume
/**
* 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();
}
代码示例来源:origin: apache/hive
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);
}
}
代码示例来源:origin: apache/drill
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);
}
代码示例来源:origin: linkedin/cruise-control
/**
* 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.");
}
代码示例来源:origin: linkedin/cruise-control
/**
* 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.");
}
代码示例来源:origin: apache/flume
/**
* 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);
}
代码示例来源:origin: thinkaurelius/titan
/**
* 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);
}
代码示例来源:origin: JanusGraph/janusgraph
/**
* 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);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void isTerminated() {
boolean result = executor.isTerminated();
verify(delegate).isTerminated();
assertThat(result).isEqualTo(delegate.isTerminated()).isNotNull();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void isTerminated() {
underTest.isTerminated();
verify(executorService).isTerminated();
}
代码示例来源:origin: linkedin/cruise-control
@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());
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
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()));
}
内容来源于网络,如有侵权,请联系作者删除!