/** * Value from {@link ThreadPoolExecutor#getTaskCount()} * * @return Number */ public Number getCurrentTaskCount() { return threadPool.getTaskCount(); }
@Override public long getPoolTaskCount() { return pool.getTaskCount(); }
/** {@inheritDoc} */ @Override public long getTaskCount() { return exec instanceof ThreadPoolExecutor ? ((ThreadPoolExecutor)exec).getTaskCount() : -1; }
@Override public long getTaskCount() { return executor.getTaskCount(); }
public int getRemainingWorkers() { return (int) (threadPoolExecutor.getTaskCount()); }
public long getTaskCount() { return executor.getTaskCount(); }
public int getProgress() { return (int) (executor.getCompletedTaskCount() * 100 / (double) executor.getTaskCount()); } }
/** * 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()); }
@com.netflix.servo.annotations.Monitor(name = "taskCount", type = COUNTER) long getTaskCount() { return pool.getTaskCount(); } }
public Long value() { return executor.getTaskCount() - executor.getCompletedTaskCount(); } });
@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); }
@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); }
+ ", largest:" + tp.getLargestPoolSize() + ", active:" + tp.getActiveCount() + ", task:" + tp.getTaskCount() + ", service port: " + port);
+ ", largest:" + tp.getLargestPoolSize() + ", active:" + tp.getActiveCount() + ", task:" + tp.getTaskCount() + ", service port: " + port);
@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); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (i++ % 7 == 0) { i = 1; if (LOGGER.isWarnEnabled()) { LOGGER.warn("Task:{} has been reject because of threadPool exhausted!" + " pool:{}, active:{}, queue:{}, taskcnt: {}", r, executor.getPoolSize(), executor.getActiveCount(), executor.getQueue().size(), executor.getTaskCount()); } } throw new RejectedExecutionException("Callback handler thread pool has bean exhausted"); } };
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (i++ % 7 == 0) { i = 1; if (LOGGER.isWarnEnabled()) { LOGGER.warn("Task:{} has been reject because of threadPool exhausted!" + " pool:{}, active:{}, queue:{}, taskcnt: {}", r, executor.getPoolSize(), executor.getActiveCount(), executor.getQueue().size(), executor.getTaskCount()); } } throw new RejectedExecutionException("Callback handler thread pool has bean exhausted"); } };
@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(); } } };
@Signature public Memory getTaskCount(Environment env, Memory... args) { if (service instanceof ThreadPoolExecutor) { return LongMemory.valueOf(((ThreadPoolExecutor) service).getTaskCount()); } return Memory.NULL; }
private void rejectMessage(ChannelHandlerContext ctx, NettyMessage msg) { if (msg.isRequest()) { DefaultResponse response = new DefaultResponse(); response.setRequestId(msg.getRequestId()); response.setException(new MotanServiceException("process thread pool is full, reject by server: " + ctx.channel().localAddress(), MotanErrorMsgConstant.SERVICE_REJECT)); sendResponse(ctx, response); LoggerUtil.error("process thread pool is full, reject, active={} poolSize={} corePoolSize={} maxPoolSize={} taskCount={} requestId={}", threadPoolExecutor.getActiveCount(), threadPoolExecutor.getPoolSize(), threadPoolExecutor.getCorePoolSize(), threadPoolExecutor.getMaximumPoolSize(), threadPoolExecutor.getTaskCount(), msg.getRequestId()); rejectCounter.incrementAndGet(); } }