diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java index 6df99c55..fe1b9476 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/TomcatWebThreadPoolHandler.java @@ -113,30 +113,18 @@ public class TomcatWebThreadPoolHandler extends AbstractWebThreadPoolService { } ThreadPoolRunStateInfo runStateInfo = new ThreadPoolRunStateInfo(); org.apache.tomcat.util.threads.ThreadPoolExecutor tomcatThreadPoolExecutor = (org.apache.tomcat.util.threads.ThreadPoolExecutor) executor; - // 核心线程数 int corePoolSize = tomcatThreadPoolExecutor.getCorePoolSize(); - // 最大线程数 int maximumPoolSize = tomcatThreadPoolExecutor.getMaximumPoolSize(); - // 线程池当前线程数 (有锁) int poolSize = tomcatThreadPoolExecutor.getPoolSize(); - // 活跃线程数 (有锁) int activeCount = tomcatThreadPoolExecutor.getActiveCount(); - // 同时进入池中的最大线程数 (有锁) int largestPoolSize = tomcatThreadPoolExecutor.getLargestPoolSize(); - // 线程池中执行任务总数量 (有锁) long completedTaskCount = tomcatThreadPoolExecutor.getCompletedTaskCount(); - // 当前负载 String currentLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + ""; - // 峰值负载 String peakLoad = CalculateUtil.divide(largestPoolSize, maximumPoolSize) + ""; BlockingQueue queue = tomcatThreadPoolExecutor.getQueue(); - // 队列元素个数 int queueSize = queue.size(); - // 队列类型 String queueType = queue.getClass().getSimpleName(); - // 队列剩余容量 int remainingCapacity = queue.remainingCapacity(); - // 队列容量 int queueCapacity = queueSize + remainingCapacity; runStateInfo.setCoreSize(corePoolSize); runStateInfo.setPoolSize(poolSize); diff --git a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java index 90ba9b7f..79cf7f01 100644 --- a/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java +++ b/hippo4j-adapter/hippo4j-adapter-web/src/main/java/cn/hippo4j/adapter/web/UndertowWebThreadPoolHandler.java @@ -103,27 +103,20 @@ public class UndertowWebThreadPoolHandler extends AbstractWebThreadPoolService { Field field = ReflectionUtils.findField(XnioWorker.class, "taskPool"); ReflectionUtils.makeAccessible(field); Object fieldObject = ReflectionUtils.getField(field, xnioWorker); - // 核心线程数 Method getCorePoolSize = ReflectionUtils.findMethod(fieldObject.getClass(), "getCorePoolSize"); ReflectionUtils.makeAccessible(getCorePoolSize); int corePoolSize = (int) ReflectionUtils.invokeMethod(getCorePoolSize, fieldObject); - // 最大线程数 Method getMaximumPoolSize = ReflectionUtils.findMethod(fieldObject.getClass(), "getMaximumPoolSize"); ReflectionUtils.makeAccessible(getMaximumPoolSize); int maximumPoolSize = (int) ReflectionUtils.invokeMethod(getMaximumPoolSize, fieldObject); - // 线程池当前线程数 (有锁) Method getPoolSize = ReflectionUtils.findMethod(fieldObject.getClass(), "getPoolSize"); ReflectionUtils.makeAccessible(getPoolSize); int poolSize = (int) ReflectionUtils.invokeMethod(getPoolSize, fieldObject); - // 活跃线程数 (有锁) Method getActiveCount = ReflectionUtils.findMethod(fieldObject.getClass(), "getActiveCount"); ReflectionUtils.makeAccessible(getActiveCount); int activeCount = (int) ReflectionUtils.invokeMethod(getActiveCount, fieldObject); activeCount = Math.max(activeCount, 0); - // 当前负载 String currentLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + ""; - // 峰值负载 - // 没有峰值记录,直接使用当前数据 String peakLoad = CalculateUtil.divide(activeCount, maximumPoolSize) + ""; stateInfo.setCoreSize(corePoolSize); stateInfo.setPoolSize(poolSize);