|
|
|
@ -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);
|
|
|
|
|