java.util.concurrent.ScheduledThreadPoolExecutor.isTerminating()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(249)

本文整理了Java中java.util.concurrent.ScheduledThreadPoolExecutor.isTerminating()方法的一些代码示例,展示了ScheduledThreadPoolExecutor.isTerminating()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledThreadPoolExecutor.isTerminating()方法的具体详情如下:
包路径:java.util.concurrent.ScheduledThreadPoolExecutor
类名称:ScheduledThreadPoolExecutor
方法名:isTerminating

ScheduledThreadPoolExecutor.isTerminating介绍

暂无

代码示例

代码示例来源:origin: ehcache/ehcache3

public boolean isTerminating() {
 return scheduler.isTerminating();
}

代码示例来源:origin: apache/flink

@Override
public void awaitPendingAfterQuiesce() throws InterruptedException {
  if (!timerService.isTerminated()) {
    Preconditions.checkState(timerService.isTerminating() || timerService.isShutdown());
    // await forever (almost)
    timerService.awaitTermination(365L, TimeUnit.DAYS);
  }
}

代码示例来源:origin: apache/flume

public synchronized void supervise(LifecycleAware lifecycleAware,
  SupervisorPolicy policy, LifecycleState desiredState) {
 if (this.monitorService.isShutdown()
   || this.monitorService.isTerminated()
   || this.monitorService.isTerminating()) {
  throw new FlumeException("Supervise called on " + lifecycleAware + " " +
    "after shutdown has been initiated. " + lifecycleAware + " will not" +
    " be started");
 }
 Preconditions.checkState(!supervisedProcesses.containsKey(lifecycleAware),
   "Refusing to supervise " + lifecycleAware + " more than once");
 if (logger.isDebugEnabled()) {
  logger.debug("Supervising service:{} policy:{} desiredState:{}",
    new Object[] { lifecycleAware, policy, desiredState });
 }
 Supervisoree process = new Supervisoree();
 process.status = new Status();
 process.policy = policy;
 process.status.desiredState = desiredState;
 process.status.error = false;
 MonitorRunnable monitorRunnable = new MonitorRunnable();
 monitorRunnable.lifecycleAware = lifecycleAware;
 monitorRunnable.supervisoree = process;
 monitorRunnable.monitorService = monitorService;
 supervisedProcesses.put(lifecycleAware, process);
 ScheduledFuture<?> future = monitorService.scheduleWithFixedDelay(
   monitorRunnable, 0, 3, TimeUnit.SECONDS);
 monitorFutures.put(lifecycleAware, future);
}

代码示例来源:origin: org.ehcache/ehcache

public boolean isTerminating() {
 return scheduler.isTerminating();
}

代码示例来源:origin: MavoCz/smscsim

private void resetSendScheduler() {
  if (sendScheduler != null && !sendScheduler.isTerminating()) {
    // Cancel scheduled but not started task, and avoid new ones
    sendScheduler.shutdown();
    // Wait for the running tasks
    try {
      sendScheduler.awaitTermination(5, TimeUnit.SECONDS);
    } catch (InterruptedException ex) {
      logger.warn("Interupt during awating termination", ex);
    }
    // Interrupt the threads and shutdown the scheduler
    sendScheduler.shutdownNow();
  }
  sendScheduler = new ScheduledThreadPoolExecutor(1);
}

代码示例来源:origin: posicks/mdnsjava

public boolean isScheduledExecutorOperational()
{
  return !scheduledExecutor.isShutdown() && !scheduledExecutor.isTerminated() && !scheduledExecutor.isTerminating();
}

代码示例来源:origin: actframework/actframework

@Command(value = "act.job.scheduler", help = "Show Job manager scheduler status")
public String getSchedulerStatus(JobManager jobManager) {
  ScheduledThreadPoolExecutor executor = jobManager.executor();
  JSONObject json = new JSONObject();
  json.put("is terminating", executor.isTerminating());
  json.put("is terminated", executor.isTerminated());
  json.put("is shutdown", executor.isShutdown());
  json.put("# of runnable in the queue", executor.getQueue().size());
  json.put("active count", executor.getActiveCount());
  json.put("# of completed tasks", executor.getActiveCount());
  json.put("core pool size", executor.getCorePoolSize());
  json.put("pool size", executor.getPoolSize());
  return json.toJSONString();
}

代码示例来源:origin: org.actframework/act

@Command(value = "act.job.scheduler", help = "Show Job manager scheduler status")
public String getSchedulerStatus(JobManager jobManager) {
  ScheduledThreadPoolExecutor executor = jobManager.executor();
  JSONObject json = new JSONObject();
  json.put("is terminating", executor.isTerminating());
  json.put("is terminated", executor.isTerminated());
  json.put("is shutdown", executor.isShutdown());
  json.put("# of runnable in the queue", executor.getQueue().size());
  json.put("active count", executor.getActiveCount());
  json.put("# of completed tasks", executor.getActiveCount());
  json.put("core pool size", executor.getCorePoolSize());
  json.put("pool size", executor.getPoolSize());
  return json.toJSONString();
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-timeline-pluginstorage

@Override
protected void serviceStop() throws Exception {
 LOG.info("Stopping {}", getName());
 stopExecutors.set(true);
 if (executor != null) {
  executor.shutdown();
  if (executor.isTerminating()) {
   LOG.info("Waiting for executor to terminate");
   boolean terminated = executor.awaitTermination(10, TimeUnit.SECONDS);
   if (terminated) {
    LOG.info("Executor terminated");
   } else {
    LOG.warn("Executor did not terminate");
    executor.shutdownNow();
   }
  }
 }
 synchronized (cachedLogs) {
  for (EntityCacheItem cacheItem : cachedLogs.values()) {
   ServiceOperations.stopQuietly(cacheItem.getStore());
  }
 }
 CallerContext.setCurrent(null);
 super.serviceStop();
}

代码示例来源:origin: org.apache.flume/flume-ng-core

public synchronized void supervise(LifecycleAware lifecycleAware,
  SupervisorPolicy policy, LifecycleState desiredState) {
 if (this.monitorService.isShutdown()
   || this.monitorService.isTerminated()
   || this.monitorService.isTerminating()) {
  throw new FlumeException("Supervise called on " + lifecycleAware + " " +
    "after shutdown has been initiated. " + lifecycleAware + " will not" +
    " be started");
 }
 Preconditions.checkState(!supervisedProcesses.containsKey(lifecycleAware),
   "Refusing to supervise " + lifecycleAware + " more than once");
 if (logger.isDebugEnabled()) {
  logger.debug("Supervising service:{} policy:{} desiredState:{}",
    new Object[] { lifecycleAware, policy, desiredState });
 }
 Supervisoree process = new Supervisoree();
 process.status = new Status();
 process.policy = policy;
 process.status.desiredState = desiredState;
 process.status.error = false;
 MonitorRunnable monitorRunnable = new MonitorRunnable();
 monitorRunnable.lifecycleAware = lifecycleAware;
 monitorRunnable.supervisoree = process;
 monitorRunnable.monitorService = monitorService;
 supervisedProcesses.put(lifecycleAware, process);
 ScheduledFuture<?> future = monitorService.scheduleWithFixedDelay(
   monitorRunnable, 0, 3, TimeUnit.SECONDS);
 monitorFutures.put(lifecycleAware, future);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-timeline-plugins

@Override
protected void serviceStop() throws Exception {
 LOG.info("Stopping {}", getName());
 if (executor != null) {
  executor.shutdown();
  if (executor.isTerminating()) {
   LOG.info("Waiting for executor to terminate");
   boolean terminated = executor.awaitTermination(10, TimeUnit.SECONDS);
   if (terminated) {
    LOG.info("Executor terminated");
   } else {
    LOG.warn("Executor did not terminate");
    executor.shutdownNow();
   }
  }
 }
 if (summaryTdm != null) {
  summaryTdm.stop();
 }
 if (summaryStore != null) {
  summaryStore.stop();
 }
 if (yarnClient != null) {
  yarnClient.stop();
 }
 super.serviceStop();
}

代码示例来源:origin: org.apache.flink/flink-streaming-java

@Override
public void awaitPendingAfterQuiesce() throws InterruptedException {
  if (!timerService.isTerminated()) {
    Preconditions.checkState(timerService.isTerminating() || timerService.isShutdown());
    // await forever (almost)
    timerService.awaitTermination(365L, TimeUnit.DAYS);
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-timeline-plugins

@Override
protected void serviceStop() throws Exception {
 LOG.info("Stopping {}", getName());
 if (executor != null) {
  executor.shutdown();
  if (executor.isTerminating()) {
   LOG.info("Waiting for executor to terminate");
   boolean terminated = executor.awaitTermination(10, TimeUnit.SECONDS);
   if (terminated) {
    LOG.info("Executor terminated");
   } else {
    LOG.warn("Executor did not terminate");
    executor.shutdownNow();
   }
  }
 }
 if (summaryTdm != null) {
  summaryTdm.stop();
 }
 if (summaryStore != null) {
  summaryStore.stop();
 }
 if (yarnClient != null) {
  yarnClient.stop();
 }
 CallerContext.setCurrent(null);
 super.serviceStop();
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.11

@Override
public void awaitPendingAfterQuiesce() throws InterruptedException {
  if (!timerService.isTerminated()) {
    Preconditions.checkState(timerService.isTerminating() || timerService.isShutdown());
    // await forever (almost)
    timerService.awaitTermination(365L, TimeUnit.DAYS);
  }
}

代码示例来源:origin: sboesebeck/morphium

while (true) {
  try {
    if (!decouplePool.isTerminated() && !decouplePool.isTerminating() && !decouplePool.isShutdown()) {

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法