/** * Return the current pool size. * @see java.util.concurrent.ThreadPoolExecutor#getPoolSize() */ public int getPoolSize() { if (this.threadPoolExecutor == null) { // Not initialized yet: assume core pool size. return this.corePoolSize; } return this.threadPoolExecutor.getPoolSize(); }
/** * Return the current pool size. * @see java.util.concurrent.ThreadPoolExecutor#getPoolSize() */ public int getPoolSize() { if (this.threadPoolExecutor == null) { // Not initialized yet: assume core pool size. return this.corePoolSize; } return this.threadPoolExecutor.getPoolSize(); }
/** * Value from {@link ThreadPoolExecutor#getPoolSize()} * * @return Number */ public Number getCurrentPoolSize() { return threadPool.getPoolSize(); }
@Override public int getWorkerCount() { return delegate.getPoolSize(); }
@Override public Object getValue() { return backgroundOperationPool.getPoolSize(); } });
@Override public String statisticCallback() { int count = rejectCounter.getAndSet(0); if (count > 0) { return String.format("type: motan name: reject_request_pool total_count: %s reject_count: %s", threadPoolExecutor.getPoolSize(), count); } else { return null; } } }
@Override public String statisticCallback() { int count = rejectCounter.getAndSet(0); if (count > 0) { return String.format("type: motan name: reject_request_pool total_count: %s reject_count: %s", threadPoolExecutor.getPoolSize(), count); } else { return null; } } }
@Override public Integer value() { return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount(); } });
@VisibleForTesting static int getCurrentThreadPoolSize() { synchronized (Context.class) { return (threadPool instanceof ThreadPoolExecutor) ? ((ThreadPoolExecutor)threadPool).getPoolSize() : ((threadPool == null) ? 0 : -1); } }
@Override public Integer value() { return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount(); } });
public static Map<String, Object> getPoolInfo(ThreadPoolExecutor executor) { Map<String, Object> info = new HashMap<>(5); info.put("corePoolSize", executor.getCorePoolSize()); info.put("maxPoolSize", executor.getMaximumPoolSize()); info.put("activeCount(workingThread)", executor.getActiveCount()); info.put("poolSize(workThread)", executor.getPoolSize()); info.put("queueSize(blockedTask)", executor.getQueue().size()); return info; }
@JmxGetter(name = "TotalStorageWorkerThreads", description = "The total number of Storage worker threads, active and idle.") public int getAllThreadInWorkerPool() { if(this.threadPoolExecutor != null) { return this.threadPoolExecutor.getPoolSize(); } else { return -1; } }
@ManagedAttribute(description="Current number of threads in the internal thread pool") public int getInternalThreadPoolSize() { if(internal_pool instanceof ThreadPoolExecutor) return ((ThreadPoolExecutor)internal_pool).getPoolSize(); return 0; }
/** * 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()); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(), executor.getPoolSize(), executor.getLargestPoolSize(), executor .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue() .size(), executor.getQueue().remainingCapacity())); } throw new RejectedExecutionException(); } }
@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); }
@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); }
@ManagedAttribute(description="Current number of threads in the thread pool") public int getThreadPoolSize() { if(thread_pool instanceof ThreadPoolExecutor) return ((ThreadPoolExecutor)thread_pool).getPoolSize(); if(thread_pool instanceof ForkJoinPool) return ((ForkJoinPool)thread_pool).getPoolSize(); return 0; }
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(); } }