diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DynamicThreadPoolAutoConfiguration.java index 7ff48524..a3381fe8 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -3,7 +3,7 @@ package cn.hippo4j.starter.config; import cn.hippo4j.common.api.ThreadDetailState; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.core.config.UtilAutoConfiguration; -import cn.hippo4j.core.refresh.ThreadPoolDynamicRefresh; +import cn.hippo4j.starter.core.ServerThreadPoolDynamicRefresh; import cn.hippo4j.core.toolkit.IdentifyUtil; import cn.hippo4j.core.toolkit.inet.InetUtils; import cn.hippo4j.starter.controller.PoolRunStateController; @@ -87,7 +87,7 @@ public class DynamicThreadPoolAutoConfiguration { public DynamicThreadPoolPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent, ThreadPoolOperation threadPoolOperation, ApplicationContextHolder hippo4JApplicationContextHolder, - ThreadPoolDynamicRefresh threadPoolDynamicRefresh) { + ServerThreadPoolDynamicRefresh threadPoolDynamicRefresh) { return new DynamicThreadPoolPostProcessor(properties, httpAgent, threadPoolOperation, threadPoolDynamicRefresh); } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/MessageNotifyConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/MessageNotifyConfiguration.java index 803d9f3a..0044a4b2 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/MessageNotifyConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/MessageNotifyConfiguration.java @@ -1,11 +1,12 @@ package cn.hippo4j.starter.config; +import cn.hippo4j.common.api.NotifyConfigBuilder; import cn.hippo4j.common.notify.*; import cn.hippo4j.common.notify.platform.DingSendMessageHandler; import cn.hippo4j.common.notify.platform.LarkSendMessageHandler; import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler; import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; -import cn.hippo4j.core.refresh.ThreadPoolDynamicRefresh; +import cn.hippo4j.starter.core.ServerThreadPoolDynamicRefresh; import cn.hippo4j.starter.notify.ServerNotifyConfigBuilder; import cn.hippo4j.starter.remote.HttpAgent; import lombok.AllArgsConstructor; @@ -59,8 +60,8 @@ public class MessageNotifyConfiguration { } @Bean - public ThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler) { - return new ThreadPoolDynamicRefresh(threadPoolNotifyAlarmHandler); + public ServerThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler) { + return new ServerThreadPoolDynamicRefresh(threadPoolNotifyAlarmHandler); } } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java index bd7dca8c..da5a1f0f 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPoolPostProcessor.java @@ -13,7 +13,6 @@ import cn.hippo4j.core.executor.DynamicThreadPoolWrapper; import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.*; -import cn.hippo4j.core.refresh.ThreadPoolDynamicRefresh; import cn.hippo4j.starter.config.BootstrapProperties; import cn.hippo4j.starter.remote.HttpAgent; import cn.hippo4j.core.toolkit.inet.DynamicThreadPoolAnnotationUtil; @@ -50,7 +49,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { private final ThreadPoolOperation threadPoolOperation; - private final ThreadPoolDynamicRefresh threadPoolDynamicRefresh; + private final ServerThreadPoolDynamicRefresh threadPoolDynamicRefresh; private final ExecutorService executorService = ThreadPoolBuilder.builder() .corePoolSize(2) @@ -193,7 +192,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { */ protected void subscribeConfig(DynamicThreadPoolWrapper dynamicThreadPoolWrap) { if (dynamicThreadPoolWrap.isSubscribeFlag()) { - threadPoolOperation.subscribeConfig(dynamicThreadPoolWrap.getTpId(), executorService, config -> threadPoolDynamicRefresh.refreshDynamicPool(config)); + threadPoolOperation.subscribeConfig(dynamicThreadPoolWrap.getTpId(), executorService, config -> threadPoolDynamicRefresh.dynamicRefresh(config)); } } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/refresh/ThreadPoolDynamicRefresh.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ServerThreadPoolDynamicRefresh.java similarity index 94% rename from hippo4j-core/src/main/java/cn/hippo4j/core/refresh/ThreadPoolDynamicRefresh.java rename to hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ServerThreadPoolDynamicRefresh.java index 1f4bd6ce..74ae3c6b 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/refresh/ThreadPoolDynamicRefresh.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ServerThreadPoolDynamicRefresh.java @@ -1,6 +1,7 @@ -package cn.hippo4j.core.refresh; +package cn.hippo4j.starter.core; import cn.hippo4j.common.enums.EnableEnum; +import cn.hippo4j.common.model.PoolParameter; import cn.hippo4j.common.model.PoolParameterInfo; import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest; import cn.hippo4j.common.toolkit.JSONUtil; @@ -12,6 +13,7 @@ import cn.hippo4j.core.executor.support.QueueTypeEnum; import cn.hippo4j.core.executor.support.RejectedTypeEnum; import cn.hippo4j.core.executor.support.ResizableCapacityLinkedBlockIngQueue; import cn.hippo4j.core.proxy.RejectedProxyUtil; +import cn.hippo4j.common.api.ThreadPoolDynamicRefresh; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -22,23 +24,19 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; /** - * ThreadPool dynamic refresh. + * Thread pool dynamic refresh. * * @author chen.ma * @date 2021/6/20 15:51 */ @Slf4j @AllArgsConstructor -public class ThreadPoolDynamicRefresh { +public class ServerThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh { private final ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler; - /** - * Refresh dynamic pool. - * - * @param content - */ - public void refreshDynamicPool(String content) { + @Override + public void dynamicRefresh(String content) { PoolParameterInfo parameter = JSONUtil.parseObject(content, PoolParameterInfo.class); String threadPoolId = parameter.getTpId(); @@ -53,7 +51,7 @@ public class ThreadPoolDynamicRefresh { * @param parameter * @param executor */ - public void refreshDynamicPool(PoolParameterInfo parameter, ThreadPoolExecutor executor) { + public void refreshDynamicPool(PoolParameter parameter, ThreadPoolExecutor executor) { String threadPoolId = parameter.getTpId(); int originalCoreSize = executor.getCorePoolSize(); int originalMaximumPoolSize = executor.getMaximumPoolSize(); @@ -119,7 +117,7 @@ public class ThreadPoolDynamicRefresh { * @param executor * @param parameter */ - public void changePoolInfo(ThreadPoolExecutor executor, PoolParameterInfo parameter) { + public void changePoolInfo(ThreadPoolExecutor executor, PoolParameter parameter) { if (parameter.getCoreSize() != null) { executor.setCorePoolSize(parameter.getCoreSize()); }