diff --git a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index c1ac69dc..e7b7ef85 100644 --- a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -53,6 +53,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.info.BuildProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Import; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; @@ -112,6 +113,7 @@ public class DynamicThreadPoolAutoConfiguration { } @Bean + @DependsOn("hippo4jApplicationContextHolder") public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor() { return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties); } diff --git a/threadpool/core/src/main/java/cn/hippo4j/core/executor/state/ThreadPoolRunStateHandler.java b/threadpool/core/src/main/java/cn/hippo4j/core/executor/state/ThreadPoolRunStateHandler.java index 992c10b4..8f77e0c6 100644 --- a/threadpool/core/src/main/java/cn/hippo4j/core/executor/state/ThreadPoolRunStateHandler.java +++ b/threadpool/core/src/main/java/cn/hippo4j/core/executor/state/ThreadPoolRunStateHandler.java @@ -68,7 +68,8 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime { String rejectedName; rejectedName = pool.getRejectedExecutionHandler().getClass().getSimpleName(); poolRunStateInfo.setRejectedName(rejectedName); - ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, ManyThreadPoolRunStateInfo.class); + + ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = convert(poolRunStateInfo); manyThreadPoolRunStateInfo.setIdentify(CLIENT_IDENTIFICATION_VALUE); String active = environment.getProperty("spring.profiles.active", "UNKNOWN"); manyThreadPoolRunStateInfo.setActive(active.toUpperCase()); @@ -76,4 +77,31 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime { manyThreadPoolRunStateInfo.setState(threadPoolState); return manyThreadPoolRunStateInfo; } + + private ManyThreadPoolRunStateInfo convert(ThreadPoolRunStateInfo poolRunStateInfo) { + ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = new ManyThreadPoolRunStateInfo(); + manyThreadPoolRunStateInfo.setCurrentLoad(poolRunStateInfo.getCurrentLoad()); + manyThreadPoolRunStateInfo.setPeakLoad(poolRunStateInfo.getPeakLoad()); + manyThreadPoolRunStateInfo.setTpId(poolRunStateInfo.getTpId()); + manyThreadPoolRunStateInfo.setActiveCount(poolRunStateInfo.getActiveCount()); + manyThreadPoolRunStateInfo.setPoolSize(poolRunStateInfo.getPoolSize()); + manyThreadPoolRunStateInfo.setActiveSize(poolRunStateInfo.getActiveSize()); + manyThreadPoolRunStateInfo.setLargestPoolSize(poolRunStateInfo.getLargestPoolSize()); + manyThreadPoolRunStateInfo.setQueueSize(poolRunStateInfo.getQueueSize()); + manyThreadPoolRunStateInfo.setQueueRemainingCapacity(poolRunStateInfo.getQueueRemainingCapacity()); + manyThreadPoolRunStateInfo.setCompletedTaskCount(poolRunStateInfo.getCompletedTaskCount()); + manyThreadPoolRunStateInfo.setRejectCount(poolRunStateInfo.getRejectCount()); + manyThreadPoolRunStateInfo.setHost(poolRunStateInfo.getHost()); + manyThreadPoolRunStateInfo.setMemoryProportion(poolRunStateInfo.getMemoryProportion()); + manyThreadPoolRunStateInfo.setFreeMemory(poolRunStateInfo.getFreeMemory()); + manyThreadPoolRunStateInfo.setClientLastRefreshTime(poolRunStateInfo.getClientLastRefreshTime()); + manyThreadPoolRunStateInfo.setTimestamp(poolRunStateInfo.getTimestamp()); + manyThreadPoolRunStateInfo.setCoreSize(poolRunStateInfo.getCoreSize()); + manyThreadPoolRunStateInfo.setMaximumSize(poolRunStateInfo.getMaximumSize()); + manyThreadPoolRunStateInfo.setQueueType(poolRunStateInfo.getQueueType()); + manyThreadPoolRunStateInfo.setQueueCapacity(poolRunStateInfo.getQueueCapacity()); + manyThreadPoolRunStateInfo.setRejectedName(poolRunStateInfo.getRejectedName()); + manyThreadPoolRunStateInfo.setKeepAliveTime(poolRunStateInfo.getKeepAliveTime()); + return manyThreadPoolRunStateInfo; + } }