本文整理了Java中java.util.concurrent.ThreadPoolExecutor.getCompletedTaskCount()
方法的一些代码示例,展示了ThreadPoolExecutor.getCompletedTaskCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.getCompletedTaskCount()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:getCompletedTaskCount
[英]Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.
[中]返回已完成执行的任务的大致总数。由于任务和线程的状态在计算过程中可能会动态变化,因此返回的值只是一个近似值,但在连续调用中不会减少。
代码示例来源:origin: PipelineAI/pipeline
/**
* Value from {@link ThreadPoolExecutor#getCompletedTaskCount()}
*
* @return Number
*/
public Number getCurrentCompletedTaskCount() {
return threadPool.getCompletedTaskCount();
}
代码示例来源:origin: apache/hbase
@Override
public long getPoolCompletedTaskCount() {
return pool.getCompletedTaskCount();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public long getCompletedTaskCount() {
return exec instanceof ThreadPoolExecutor ? ((ThreadPoolExecutor)exec).getCompletedTaskCount() : -1;
}
代码示例来源:origin: jmxtrans/jmxtrans
@Override
public long getCompletedTaskCount() {
return executor.getCompletedTaskCount();
}
代码示例来源:origin: rapidoid/rapidoid
public long getCompletedTaskCount() {
return executor.getCompletedTaskCount();
}
}
代码示例来源:origin: lealone/Lealone
public Long value() {
return executor.getCompletedTaskCount();
}
});
代码示例来源:origin: skylot/jadx
public int getProgress() {
return (int) (executor.getCompletedTaskCount() * 100 / (double) executor.getTaskCount());
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Return status information about the underlying threadpool.
*/
@Override
public String toString() {
return String.format("active: %d/%d submitted: %d completed: %d input_q: %d output_q: %d idle_q: %d",
threadPool.getActiveCount(),
threadPool.getPoolSize(),
threadPool.getTaskCount(),
threadPool.getCompletedTaskCount(),
threadPool.getQueue().size(),
outputQueue.size(),
idleProcessors.size());
}
代码示例来源:origin: blynkkk/blynk-server
BlockingIOStat(BlockingIOProcessor blockingIOProcessor, ReportScheduler reportScheduler) {
this(blockingIOProcessor.messagingExecutor.getQueue().size(),
blockingIOProcessor.messagingExecutor.getCompletedTaskCount(),
blockingIOProcessor.historyExecutor.getQueue().size(),
blockingIOProcessor.historyExecutor.getCompletedTaskCount(),
blockingIOProcessor.dbExecutor.getQueue().size(),
blockingIOProcessor.dbExecutor.getCompletedTaskCount(),
blockingIOProcessor.dbGetServerExecutor.getQueue().size(),
blockingIOProcessor.dbGetServerExecutor.getCompletedTaskCount(),
reportScheduler.getQueue().size(),
reportScheduler.getCompletedTaskCount(),
reportScheduler.map.size()
);
}
代码示例来源:origin: Netflix/servo
@com.netflix.servo.annotations.Monitor(name = "completedTaskCount", type = COUNTER)
long getCompletedTaskCount() {
return pool.getCompletedTaskCount();
}
代码示例来源:origin: lealone/Lealone
public Long value() {
return executor.getTaskCount() - executor.getCompletedTaskCount();
}
});
代码示例来源:origin: wildfly/wildfly
@ManagedAttribute public long getThreadPoolCompletedTasks() {return thread_pool.getCompletedTaskCount();}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: vipshop/vjtools
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format(
"Thread pool is EXHAUSTED!"
+ " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d),"
+ " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s)!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(),
e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(),
e.isTerminating());
logger.warn(msg);
dummper.tryThreadDump(null);
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: skylot/jadx
@Override
public void run() {
try {
decompiler.getArgs().setRootDir(dir);
ThreadPoolExecutor ex = (ThreadPoolExecutor) decompiler.getSaveExecutor();
ex.shutdown();
while (ex.isTerminating()) {
long total = ex.getTaskCount();
long done = ex.getCompletedTaskCount();
progressMonitor.setProgress((int) (done * 100.0 / (double) total));
Thread.sleep(500);
}
progressMonitor.close();
LOG.info("decompilation complete, freeing memory ...");
decompiler.getClasses().forEach(JavaClass::unload);
LOG.info("done");
} catch (InterruptedException e) {
LOG.error("Save interrupted", e);
Thread.currentThread().interrupt();
}
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public synchronized void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
long completed = executor.getCompletedTaskCount();
if (completed < last_completed) {
throw new IllegalStateException("Number of completed tasks shouldn't decrease");
} else if (completed == last_completed) {
long now = System.currentTimeMillis();
if (now - last_change > period) {
String message = String.format(
"No progress for %d ms, possible distributed deadlock. Try raising threadpool size\n" +
"\tMin size: %d\n\tMax size: %d\n\tCurrent size: %d\n\tActive: %d\n\tLargest size: %d\n" +
"\tCompleted tasks: %d\n\tTotal scheduled: %d",
now - last_change, executor.getCorePoolSize(), executor.getMaximumPoolSize(),
executor.getPoolSize(), executor.getActiveCount(), executor.getLargestPoolSize(),
executor.getCompletedTaskCount(), executor.getTaskCount());
throw new NoProgressException(message);
}
} else {
last_change = System.currentTimeMillis();
last_completed = completed;
}
if (fallback != null) {
fallback.rejectedExecution(r, executor);
}
}
}
代码示例来源:origin: Alluxio/alluxio
private void addAbsent(AlluxioURI path) throws Exception {
final ThreadPoolExecutor pool = Whitebox.getInternalState(mUfsAbsentPathCache, "mPool");
final long initialTasks = pool.getCompletedTaskCount();
mUfsAbsentPathCache.process(path, Collections.emptyList());
// Wait until the async task is completed.
CommonUtils.waitFor("path (" + path + ") to be added to absent cache",
() -> pool.getCompletedTaskCount() != initialTasks,
WaitForOptions.defaults().setTimeoutMs(10000));
}
代码示例来源:origin: Alluxio/alluxio
private void removeAbsent(AlluxioURI path) throws Exception {
final ThreadPoolExecutor pool = Whitebox.getInternalState(mUfsAbsentPathCache, "mPool");
final long initialTasks = pool.getCompletedTaskCount();
mUfsAbsentPathCache.process(path, Collections.emptyList());
// Wait until the async task is completed.
CommonUtils.waitFor("path (" + path + ") to be removed from absent cache",
() -> pool.getCompletedTaskCount() != initialTasks,
WaitForOptions.defaults().setTimeoutMs(10000));
}
代码示例来源:origin: apache/hbase
@Test
public void testPriorityRegionIsOpenedWithSeparateThreadPool() throws Exception {
final TableName tableName = TableName.valueOf(TestRegionOpen.class.getSimpleName());
ThreadPoolExecutor exec = getRS().getExecutorService()
.getExecutorThreadPool(ExecutorType.RS_OPEN_PRIORITY_REGION);
long completed = exec.getCompletedTaskCount();
HTableDescriptor htd = new HTableDescriptor(tableName);
htd.setPriority(HConstants.HIGH_QOS);
htd.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
try (Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration());
Admin admin = connection.getAdmin()) {
admin.createTable(htd);
}
assertEquals(completed + 1, exec.getCompletedTaskCount());
}
内容来源于网络,如有侵权,请联系作者删除!