From abae0d1daaf5f55a19bbd586a0d337d6d2b813cf Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sat, 6 Aug 2022 20:44:06 +0800 Subject: [PATCH] hippo4j-core-spring-boot-starter code naming and log optimization --- .../common/model/ThreadPoolParameterInfo.java | 6 +++ .../request/ChangeParameterNotifyRequest.java | 6 +++ .../starter/common/ConfigFileTypeEnum.java | 3 -- .../config/BootstrapCoreProperties.java | 5 +-- ...ynamicThreadPoolCoreAutoConfiguration.java | 2 +- .../starter/config/ExecutorProperties.java | 23 +++++----- .../config/NotifyPlatformProperties.java | 12 ++---- .../config/WebThreadPoolProperties.java | 3 -- .../DynamicThreadPoolMonitorExecutor.java | 5 +-- .../notify/CoreNotifyConfigBuilder.java | 4 -- .../starter/parser/AbstractConfigParser.java | 4 +- .../starter/parser/ConfigFileTypeEnum.java | 17 +++----- .../starter/parser/ConfigParser.java | 4 +- .../starter/parser/ConfigParserHandler.java | 6 +-- .../parser/PropertiesConfigParser.java | 4 +- .../starter/parser/YamlConfigParser.java | 12 ++---- .../AbstractCoreThreadPoolDynamicRefresh.java | 3 -- .../refresher/ApolloRefresherHandler.java | 6 +-- .../BootstrapCorePropertiesBinderAdapt.java | 3 -- .../refresher/NacosCloudRefresherHandler.java | 4 +- .../refresher/NacosRefresherHandler.java | 5 +-- .../refresher/ZookeeperRefresherHandler.java | 11 +++-- .../refresher/event/ExecutorsListener.java | 43 ++++++++++--------- .../event/Hippo4jCoreDynamicRefreshEvent.java | 2 +- .../Hippo4jCoreDynamicRefreshEventOrder.java | 2 +- .../refresher/event/PlatformsListener.java | 6 +-- .../refresher/event/WebExecutorListener.java | 24 +++++------ .../DynamicThreadPoolPostProcessor.java | 43 ++++++++----------- .../support/GlobalCoreThreadPoolManage.java | 3 -- 29 files changed, 111 insertions(+), 160 deletions(-) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/model/ThreadPoolParameterInfo.java b/hippo4j-common/src/main/java/cn/hippo4j/common/model/ThreadPoolParameterInfo.java index 9785f0fa..175db3dc 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/model/ThreadPoolParameterInfo.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/model/ThreadPoolParameterInfo.java @@ -17,7 +17,10 @@ package cn.hippo4j.common.model; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; @@ -26,6 +29,9 @@ import java.io.Serializable; * Thread pool parameter info. */ @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor @Accessors(chain = true) public class ThreadPoolParameterInfo implements ThreadPoolParameter, Serializable { diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/request/ChangeParameterNotifyRequest.java b/hippo4j-message/src/main/java/cn/hippo4j/message/request/ChangeParameterNotifyRequest.java index 03b7796d..72e7b925 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/request/ChangeParameterNotifyRequest.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/request/ChangeParameterNotifyRequest.java @@ -18,12 +18,18 @@ package cn.hippo4j.message.request; import cn.hippo4j.message.request.base.BaseNotifyRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; /** * Change parameter notify request. */ @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class ChangeParameterNotifyRequest extends BaseNotifyRequest { private String active; diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/common/ConfigFileTypeEnum.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/common/ConfigFileTypeEnum.java index 6e3e9eb7..4fc820a1 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/common/ConfigFileTypeEnum.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/common/ConfigFileTypeEnum.java @@ -19,9 +19,6 @@ package cn.hippo4j.core.springboot.starter.common; /** * Config file type enum. - * - * @author chen.ma - * @date 2022/2/26 18:12 */ public enum ConfigFileTypeEnum { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java index eddc95be..93696763 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java @@ -27,10 +27,7 @@ import java.util.List; import java.util.Map; /** - * Bootstrap properties. - * - * @author chen.ma - * @date 2022/2/25 00:35 + * Bootstrap core properties. */ @Getter @Setter diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java index aca64a74..ec672a43 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java @@ -48,7 +48,7 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; /** - * Dynamic thread-pool core auto-configuration. + * Dynamic thread-pool core auto configuration. */ @Configuration @AllArgsConstructor diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/ExecutorProperties.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/ExecutorProperties.java index d4c32e42..dbcf4973 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/ExecutorProperties.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/ExecutorProperties.java @@ -27,61 +27,58 @@ import java.util.Objects; /** * Executor properties. - * - * @author chen.ma - * @date 2022/2/25 00:40 */ @Data @Accessors(chain = true) public class ExecutorProperties { /** - * threadPoolId + * Thread pool id */ private String threadPoolId; /** - * corePoolSize + * Core pool size */ private Integer corePoolSize; /** - * maximumPoolSize + * Maximum pool size */ private Integer maximumPoolSize; /** - * queueCapacity + * Queue capacity */ private Integer queueCapacity; /** - * blockingQueue + * Blocking queue */ private String blockingQueue; /** - * rejectedHandler + * Rejected handler */ private String rejectedHandler; /** - * keepAliveTime + * Keep alive time */ private Long keepAliveTime; /** - * executeTimeOut + * Execute timeout */ private Long executeTimeOut; /** - * allowCoreThreadTimeOut + * Allow core thread timeout */ private Boolean allowCoreThreadTimeOut; /** - * threadNamePrefix + * Thread name prefix */ private String threadNamePrefix; diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/NotifyPlatformProperties.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/NotifyPlatformProperties.java index 5d3ed5c3..6b645de0 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/NotifyPlatformProperties.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/NotifyPlatformProperties.java @@ -21,32 +21,28 @@ import lombok.Data; /** * Notify platform properties. - * - * @author chen.ma - * @date 2022/2/25 19:29 */ @Data public class NotifyPlatformProperties { /** - * Platform. + * Platform */ private String platform; /** - * Secret key. - * {@link NotifyPlatformProperties#token} + * Secret key. {@link NotifyPlatformProperties#token} */ @Deprecated private String secretKey; /** - * Token. + * Token */ private String token; /** - * Secret. + * Secret */ private String secret; } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/WebThreadPoolProperties.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/WebThreadPoolProperties.java index f312da42..915a0c4d 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/WebThreadPoolProperties.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/WebThreadPoolProperties.java @@ -21,9 +21,6 @@ import lombok.Data; /** * Web thread pool properties. - * - * @author chen.ma - * @date 2022/3/11 19:23 */ @Data public class WebThreadPoolProperties { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/monitor/DynamicThreadPoolMonitorExecutor.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/monitor/DynamicThreadPoolMonitorExecutor.java index a489022d..cc34d5f6 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/monitor/DynamicThreadPoolMonitorExecutor.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/monitor/DynamicThreadPoolMonitorExecutor.java @@ -38,9 +38,6 @@ import java.util.concurrent.TimeUnit; /** * Dynamic thread-pool monitor executor. - * - * @author chen.ma - * @date 2022/3/25 19:29 */ @Slf4j @RequiredArgsConstructor @@ -87,7 +84,7 @@ public class DynamicThreadPoolMonitorExecutor implements ApplicationRunner { try { each.collect(); } catch (Exception ex) { - log.error("Error monitoring the running status of dynamic thread pool. Type :: {}", each.getType(), ex); + log.error("Error monitoring the running status of dynamic thread pool. Type: {}", each.getType(), ex); } } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java index 3c05ba02..0aba2ac6 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java @@ -38,9 +38,6 @@ import java.util.stream.Collectors; /** * Core notify config builder. - * - * @author chen.ma - * @date 2022/2/25 00:24 */ @AllArgsConstructor @Slf4j @@ -139,7 +136,6 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder { receive = receives.get(platformProperties.getPlatform()); } } - return receive; } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/AbstractConfigParser.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/AbstractConfigParser.java index 4224d2d1..72822277 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/AbstractConfigParser.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/AbstractConfigParser.java @@ -18,9 +18,7 @@ package cn.hippo4j.core.springboot.starter.parser; /** - * @author : wh - * @date : 2022/3/1 07:50 - * @description: + * Abstract config parser */ public abstract class AbstractConfigParser implements ConfigParser { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigFileTypeEnum.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigFileTypeEnum.java index ed4a5c6e..91819d60 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigFileTypeEnum.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigFileTypeEnum.java @@ -20,40 +20,38 @@ package cn.hippo4j.core.springboot.starter.parser; import lombok.Getter; /** - * @author : wh - * @date : 2022/3/1 07:47 - * @description: + * Config file type enum */ @Getter public enum ConfigFileTypeEnum { /** - * properties + * PROPERTIES */ PROPERTIES("properties"), /** - * xml + * XML */ XML("xml"), /** - * json + * JSON */ JSON("json"), /** - * yml + * YML */ YML("yml"), /** - * yaml + * YAML */ YAML("yaml"), /** - * txt + * TXT */ TXT("txt"); @@ -71,5 +69,4 @@ public enum ConfigFileTypeEnum { } return PROPERTIES; } - } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParser.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParser.java index 66bbf2c9..e0a98ba7 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParser.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParser.java @@ -22,9 +22,7 @@ import java.util.List; import java.util.Map; /** - * @author : wh - * @date : 2022/3/1 07:47 - * @description: + * Config parser. */ public interface ConfigParser { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParserHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParserHandler.java index 4053c8de..0a02d466 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParserHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/ConfigParserHandler.java @@ -26,9 +26,7 @@ import java.util.Map; import java.util.ServiceLoader; /** - * @author : wh - * @date : 2022/3/1 08:02 - * @description: + * Config parser handler. */ public class ConfigParserHandler { @@ -39,7 +37,6 @@ public class ConfigParserHandler { for (ConfigParser configParser : loader) { PARSERS.add(configParser); } - PARSERS.add(new PropertiesConfigParser()); PARSERS.add(new YamlConfigParser()); } @@ -50,7 +47,6 @@ public class ConfigParserHandler { return parser.doParse(content); } } - return Collections.emptyMap(); } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/PropertiesConfigParser.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/PropertiesConfigParser.java index 7dc2eae3..9fb118d2 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/PropertiesConfigParser.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/PropertiesConfigParser.java @@ -26,9 +26,7 @@ import java.util.Map; import java.util.Properties; /** - * @author : wh - * @date : 2022/3/1 07:49 - * @description: + * Properties config parser. */ public class PropertiesConfigParser extends AbstractConfigParser { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/YamlConfigParser.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/YamlConfigParser.java index 2da0076e..6f78ee23 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/YamlConfigParser.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/parser/YamlConfigParser.java @@ -27,9 +27,7 @@ import java.util.List; import java.util.Map; /** - * @author : wh - * @date : 2022/3/1 07:57 - * @description: + * Yaml config parser. */ public class YamlConfigParser extends AbstractConfigParser { @@ -38,11 +36,9 @@ public class YamlConfigParser extends AbstractConfigParser { if (StringUtils.isEmpty(content)) { return Maps.newHashMapWithExpectedSize(0); } - - YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean(); - bean.setResources(new ByteArrayResource(content.getBytes())); - - return bean.getObject(); + YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); + yamlPropertiesFactoryBean.setResources(new ByteArrayResource(content.getBytes())); + return yamlPropertiesFactoryBean.getObject(); } @Override diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/AbstractCoreThreadPoolDynamicRefresh.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/AbstractCoreThreadPoolDynamicRefresh.java index 5484bb5d..db75f1ca 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/AbstractCoreThreadPoolDynamicRefresh.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/AbstractCoreThreadPoolDynamicRefresh.java @@ -34,9 +34,6 @@ import java.util.concurrent.ExecutorService; /** * Abstract core thread-pool dynamic refresh. - * - * @author chen.ma - * @date 2022/2/26 12:42 */ @Slf4j @RequiredArgsConstructor diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ApolloRefresherHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ApolloRefresherHandler.java index e9960573..89ce57aa 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ApolloRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ApolloRefresherHandler.java @@ -32,9 +32,7 @@ import java.util.Map; import static cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties.PREFIX; /** - * @author : wh - * @date : 2022/2/28 21:32 - * @description: + * Apollo refresher handler. */ @Slf4j public class ApolloRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh { @@ -62,6 +60,6 @@ public class ApolloRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh dynamicRefresh(configFile.getContent(), newChangeValueMap); }; config.addChangeListener(configChangeListener); - log.info("dynamic-thread-pool refresher, add apollo listener success, namespace: {}", namespace); + log.info("Dynamic thread pool refresher, add apollo listener success. namespace: {}", namespace); } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/BootstrapCorePropertiesBinderAdapt.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/BootstrapCorePropertiesBinderAdapt.java index 7df533e9..f8bc5311 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/BootstrapCorePropertiesBinderAdapt.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/BootstrapCorePropertiesBinderAdapt.java @@ -40,9 +40,6 @@ import static cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties. /** * Bootstrap core properties binder adapt. - * - * @author chen.ma - * @date 2022/3/9 19:04 */ public class BootstrapCorePropertiesBinderAdapt { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosCloudRefresherHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosCloudRefresherHandler.java index aa064420..1afb4ad5 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosCloudRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosCloudRefresherHandler.java @@ -27,9 +27,6 @@ import java.util.concurrent.Executor; /** * Nacos cloud refresher handler. - * - * @author chen.ma - * @date 2022/2/26 11:21 */ @Slf4j public class NacosCloudRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh { @@ -56,5 +53,6 @@ public class NacosCloudRefresherHandler extends AbstractCoreThreadPoolDynamicRef dynamicRefresh(configInfo); } }); + log.info("Dynamic thread pool refresher, add nacos cloud listener success. data-id: {}, group: {}", nacosConfig.get("data-id"), nacosConfig.get("group")); } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosRefresherHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosRefresherHandler.java index 100708c0..652ed484 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/NacosRefresherHandler.java @@ -28,9 +28,6 @@ import java.util.concurrent.Executor; /** * Nacos refresher handler. - * - * @author chen.ma - * @date 2022/2/26 00:10 */ @Slf4j public class NacosRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh { @@ -59,5 +56,7 @@ public class NacosRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh dynamicRefresh(configInfo); } }); + log.info("Dynamic thread pool refresher, add nacos listener success. data-id: {}, group: {}", nacosConfig.get("data-id"), nacosConfig.get("group")); + } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java index 585e16b0..1c736094 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java @@ -36,8 +36,7 @@ import java.util.List; import java.util.Map; /** - * @author Redick01 - * @date 2022/3/14 16:03 + * Zookeeper refresher handler. */ @Slf4j public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh { @@ -93,15 +92,15 @@ public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefr String value = ""; try { value = new String(data.watched().forPath(n), Charsets.UTF_8); - } catch (Exception e) { - e.printStackTrace(); + } catch (Exception ex) { + log.error("Load zookeeper node error", ex); } content.append(nodeName).append("=").append(value).append("\n"); }); dynamicRefresh(content.toString()); registerNotifyAlarmManage(); - } catch (Exception e) { - log.error("load zk node error, nodePath is {}", nodePath, e); + } catch (Exception ex) { + log.error("Load zookeeper node error, nodePath is: {}", nodePath, ex); } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java index eafb13d2..7bfdac5b 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java @@ -98,37 +98,38 @@ public class ExecutorsListener implements ApplicationListener queue = (ResizableCapacityLinkedBlockingQueue) executor.getQueue(); queue.setCapacity(properties.getQueueCapacity()); } else { - log.warn("The queue length cannot be modified. Queue type mismatch. Current queue type :: {}", executor.getQueue().getClass().getSimpleName()); + log.warn("The queue length cannot be modified. Queue type mismatch. Current queue type: {}", executor.getQueue().getClass().getSimpleName()); } } } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEvent.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEvent.java index 9c517f7c..bb979f96 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEvent.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEvent.java @@ -23,7 +23,7 @@ import lombok.Setter; import org.springframework.context.ApplicationEvent; /** - * Hippo4j core dynamic refresh event. + * Hippo-4j core dynamic refresh event. */ public class Hippo4jCoreDynamicRefreshEvent extends ApplicationEvent { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEventOrder.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEventOrder.java index 9766c90d..72c4641f 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEventOrder.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/Hippo4jCoreDynamicRefreshEventOrder.java @@ -18,7 +18,7 @@ package cn.hippo4j.core.springboot.starter.refresher.event; /** - * Hippo4j core dynamic refresh event order. + * Hippo-4j core dynamic refresh event order. */ public interface Hippo4jCoreDynamicRefreshEventOrder { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/PlatformsListener.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/PlatformsListener.java index 8a38455f..e8034ca9 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/PlatformsListener.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/PlatformsListener.java @@ -43,13 +43,13 @@ public class PlatformsListener implements ApplicationListener executors = bindableCoreProperties.getExecutors(); - for (ExecutorProperties executor : executors) { - String threadPoolId = executor.getThreadPoolId(); + for (ExecutorProperties executorProperties : executors) { + String threadPoolId = executorProperties.getThreadPoolId(); DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId); if (wrapper != null && !wrapper.isInitFlag()) { Hippo4jBaseSendMessageService sendMessageService = ApplicationContextHolder.getBean(Hippo4jBaseSendMessageService.class); CoreNotifyConfigBuilder configBuilder = ApplicationContextHolder.getBean(CoreNotifyConfigBuilder.class); - Map> notifyConfig = configBuilder.buildSingleNotifyConfig(executor); + Map> notifyConfig = configBuilder.buildSingleNotifyConfig(executorProperties); sendMessageService.putPlatform(notifyConfig); wrapper.setInitFlag(Boolean.TRUE); } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/WebExecutorListener.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/WebExecutorListener.java index d20dbd96..e191caef 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/WebExecutorListener.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/WebExecutorListener.java @@ -63,25 +63,25 @@ public class WebExecutorListener implements ApplicationListener each.getIsAlarm()).orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true); @@ -151,18 +147,15 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { threadPoolNotifyAlarm.setInterval(interval); threadPoolNotifyAlarm.setReceive(receive); GlobalNotifyAlarmManage.put(threadPoolId, threadPoolNotifyAlarm); - - TaskDecorator taskDecorator = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrap.getExecutor()).getTaskDecorator(); + TaskDecorator taskDecorator = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrapper.getExecutor()).getTaskDecorator(); ((DynamicThreadPoolExecutor) newDynamicPoolExecutor).setTaskDecorator(taskDecorator); - - long awaitTerminationMillis = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrap.getExecutor()).awaitTerminationMillis; - boolean waitForTasksToCompleteOnShutdown = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrap.getExecutor()).waitForTasksToCompleteOnShutdown; + long awaitTerminationMillis = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrapper.getExecutor()).awaitTerminationMillis; + boolean waitForTasksToCompleteOnShutdown = ((DynamicThreadPoolExecutor) dynamicThreadPoolWrapper.getExecutor()).waitForTasksToCompleteOnShutdown; ((DynamicThreadPoolExecutor) newDynamicPoolExecutor).setSupportParam(awaitTerminationMillis, waitForTasksToCompleteOnShutdown); } - dynamicThreadPoolWrap.setExecutor(newDynamicPoolExecutor); + dynamicThreadPoolWrapper.setExecutor(newDynamicPoolExecutor); } - - GlobalThreadPoolManage.registerPool(dynamicThreadPoolWrap.getThreadPoolId(), dynamicThreadPoolWrap); + GlobalThreadPoolManage.registerPool(dynamicThreadPoolWrapper.getThreadPoolId(), dynamicThreadPoolWrapper); GlobalCoreThreadPoolManage.register( threadPoolId, executorProperties == null @@ -180,10 +173,10 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { */ private ExecutorProperties buildExecutorProperties(String threadPoolId, ThreadPoolExecutor executor) { ExecutorProperties executorProperties = new ExecutorProperties(); - BlockingQueue queue = executor.getQueue(); - int queueSize = queue.size(); - String queueType = queue.getClass().getSimpleName(); - int remainingCapacity = queue.remainingCapacity(); + BlockingQueue blockingQueue = executor.getQueue(); + int queueSize = blockingQueue.size(); + String queueType = blockingQueue.getClass().getSimpleName(); + int remainingCapacity = blockingQueue.remainingCapacity(); int queueCapacity = queueSize + remainingCapacity; executorProperties.setCorePoolSize(executor.getCorePoolSize()) .setMaximumPoolSize(executor.getMaximumPoolSize()) diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/support/GlobalCoreThreadPoolManage.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/support/GlobalCoreThreadPoolManage.java index bf5678a2..6c665023 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/support/GlobalCoreThreadPoolManage.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/support/GlobalCoreThreadPoolManage.java @@ -24,9 +24,6 @@ import java.util.Map; /** * Global core thread-pool manage. - * - * @author chen.ma - * @date 2022/2/26 19:47 */ public class GlobalCoreThreadPoolManage {