add depends on

pull/1382/head
yanrongzhen 2 years ago
parent 1e003aa074
commit 0b1d898b05

@ -53,6 +53,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.info.BuildProperties; import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -112,6 +113,7 @@ public class DynamicThreadPoolAutoConfiguration {
} }
@Bean @Bean
@DependsOn("hippo4jApplicationContextHolder")
public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor() { public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor() {
return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties); return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties);
} }

@ -68,7 +68,8 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
String rejectedName; String rejectedName;
rejectedName = pool.getRejectedExecutionHandler().getClass().getSimpleName(); rejectedName = pool.getRejectedExecutionHandler().getClass().getSimpleName();
poolRunStateInfo.setRejectedName(rejectedName); poolRunStateInfo.setRejectedName(rejectedName);
ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, ManyThreadPoolRunStateInfo.class);
ManyThreadPoolRunStateInfo manyThreadPoolRunStateInfo = convert(poolRunStateInfo);
manyThreadPoolRunStateInfo.setIdentify(CLIENT_IDENTIFICATION_VALUE); manyThreadPoolRunStateInfo.setIdentify(CLIENT_IDENTIFICATION_VALUE);
String active = environment.getProperty("spring.profiles.active", "UNKNOWN"); String active = environment.getProperty("spring.profiles.active", "UNKNOWN");
manyThreadPoolRunStateInfo.setActive(active.toUpperCase()); manyThreadPoolRunStateInfo.setActive(active.toUpperCase());
@ -76,4 +77,31 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
manyThreadPoolRunStateInfo.setState(threadPoolState); manyThreadPoolRunStateInfo.setState(threadPoolState);
return manyThreadPoolRunStateInfo; 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;
}
} }

Loading…
Cancel
Save