From e983389faf65de2ea09e09ee9d7cd3ab345f2aa0 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Fri, 6 Aug 2021 21:22:44 +0800 Subject: [PATCH] Optimize class naming and code format. --- .../starter/common/CommonThreadPool.java | 2 +- ...operties.java => BootstrapProperties.java} | 15 +++--- .../DynamicThreadPoolAutoConfiguration.java | 28 +++++----- .../starter/config/HttpClientConfig.java | 14 +---- .../controller/PoolRunStateController.java | 1 + .../threadpool/starter/core/CacheData.java | 1 + .../threadpool/starter/core/ClientWorker.java | 52 +------------------ .../starter/core/ConfigAdapter.java | 5 +- .../starter/core/ConfigService.java | 3 +- ...ient.java => DynamicThreadPoolClient.java} | 2 +- ...va => DynamicThreadPoolPostProcessor.java} | 12 ++--- .../starter/core/GlobalThreadPoolManage.java | 3 +- .../threadpool/starter/core/InstanceInfo.java | 17 +++++- .../threadpool/starter/core/Listener.java | 3 +- .../starter/core/ThreadPoolConfigService.java | 3 +- .../core/ThreadPoolDynamicRefresh.java | 2 +- .../starter/core/ThreadPoolOperation.java | 9 ++-- .../core/ThreadPoolSubscribeCallback.java | 3 +- .../enable/EnableDynamicThreadPool.java | 2 +- ...guration.java => MarkerConfiguration.java} | 3 +- ...va => DynamicThreadPoolBannerHandler.java} | 8 +-- .../handler/ThreadPoolRunStateHandler.java | 1 + .../threadpool/starter/remote/HttpAgent.java | 1 + .../starter/remote/ServerHttpAgent.java | 6 +-- .../starter/remote/ServerListManager.java | 7 ++- .../starter/spi/CustomBlockingQueue.java | 6 +-- .../spi/CustomRejectedExecutionHandler.java | 6 +-- .../starter/spi/DynamicTpServiceLoader.java | 1 + .../threadpool/starter/toolkit/ArrayUtil.java | 1 + .../starter/toolkit/HttpClientUtil.java | 2 +- .../AbstractBuildThreadPoolTemplate.java | 3 +- .../starter/toolkit/thread/Builder.java | 2 +- .../thread/FastThreadPoolExecutor.java | 4 +- .../starter/toolkit/thread/QueueTypeEnum.java | 3 +- .../toolkit/thread/RejectedPolicies.java | 3 +- .../toolkit/thread/RejectedTypeEnum.java | 2 +- .../ResizableCapacityLinkedBlockIngQueue.java | 5 +- .../starter/toolkit/thread/TaskQueue.java | 6 +-- .../toolkit/thread/ThreadFactoryBuilder.java | 3 +- .../toolkit/thread/ThreadPoolBuilder.java | 3 +- .../thread/ThreadPoolExecutorTemplate.java | 3 +- .../starter/wrap/DynamicThreadPoolWrap.java | 2 +- .../starter/wrap/ManagerListenerWrap.java | 7 +-- 43 files changed, 118 insertions(+), 147 deletions(-) rename dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/{DynamicThreadPoolProperties.java => BootstrapProperties.java} (71%) rename dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/{DynamicTpClient.java => DynamicThreadPoolClient.java} (75%) rename dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/{ThreadPoolBeanPostProcessor.java => DynamicThreadPoolPostProcessor.java} (91%) rename dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/{DynamicThreadPoolMarkerConfiguration.java => MarkerConfiguration.java} (89%) rename dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/{ThreadPoolBannerHandler.java => DynamicThreadPoolBannerHandler.java} (86%) diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/common/CommonThreadPool.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/common/CommonThreadPool.java index 173ea316..14f589ee 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/common/CommonThreadPool.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/common/CommonThreadPool.java @@ -8,7 +8,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** - * 公共线程池生产者 + * Common ThreadPool. * * @author chen.ma * @date 2021/6/16 22:35 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolProperties.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/BootstrapProperties.java similarity index 71% rename from dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolProperties.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/BootstrapProperties.java index 03993910..7c5cc248 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolProperties.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/BootstrapProperties.java @@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * 动态线程池配置 + * Bootstrap Properties. * * @author chen.ma * @date 2021/6/22 09:14 @@ -14,28 +14,29 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @Slf4j @Getter @Setter -@ConfigurationProperties(prefix = DynamicThreadPoolProperties.PREFIX) -public class DynamicThreadPoolProperties { +@ConfigurationProperties(prefix = BootstrapProperties.PREFIX) +public class BootstrapProperties { public static final String PREFIX = "spring.dynamic.thread-pool"; /** - * 服务地址 + * serverAddr */ private String serverAddr; /** - * 租户 ID + * namespace */ private String namespace; /** - * 项目 ID + * itemId */ private String itemId; /** - * 是否开启 banner + * Enable banner */ private boolean banner = true; + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolAutoConfiguration.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolAutoConfiguration.java index 9ffb9fd8..9736de9b 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -3,14 +3,13 @@ package com.github.dynamic.threadpool.starter.config; import com.github.dynamic.threadpool.common.config.ApplicationContextHolder; import com.github.dynamic.threadpool.starter.controller.PoolRunStateController; import com.github.dynamic.threadpool.starter.core.ConfigService; -import com.github.dynamic.threadpool.starter.core.ThreadPoolBeanPostProcessor; +import com.github.dynamic.threadpool.starter.core.DynamicThreadPoolPostProcessor; import com.github.dynamic.threadpool.starter.core.ThreadPoolConfigService; import com.github.dynamic.threadpool.starter.core.ThreadPoolOperation; -import com.github.dynamic.threadpool.starter.enable.DynamicThreadPoolMarkerConfiguration; -import com.github.dynamic.threadpool.starter.handler.ThreadPoolBannerHandler; +import com.github.dynamic.threadpool.starter.enable.MarkerConfiguration; +import com.github.dynamic.threadpool.starter.handler.DynamicThreadPoolBannerHandler; import com.github.dynamic.threadpool.starter.remote.HttpAgent; import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -18,24 +17,23 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * 动态线程池自动装配类 + * DynamicTp Auto Configuration. * * @author chen.ma * @date 2021/6/22 09:20 */ -@Slf4j @Configuration @AllArgsConstructor -@ImportAutoConfiguration(HttpClientConfig.class) -@EnableConfigurationProperties(DynamicThreadPoolProperties.class) -@ConditionalOnBean(DynamicThreadPoolMarkerConfiguration.Marker.class) +@EnableConfigurationProperties(BootstrapProperties.class) +@ConditionalOnBean(MarkerConfiguration.Marker.class) +@ImportAutoConfiguration({HttpClientConfig.class, DiscoveryConfig.class}) public class DynamicThreadPoolAutoConfiguration { - private final DynamicThreadPoolProperties properties; + private final BootstrapProperties properties; @Bean - public ThreadPoolBannerHandler threadPoolBannerHandler() { - return new ThreadPoolBannerHandler(properties); + public DynamicThreadPoolBannerHandler threadPoolBannerHandler() { + return new DynamicThreadPoolBannerHandler(properties); } @Bean @@ -56,8 +54,8 @@ public class DynamicThreadPoolAutoConfiguration { @Bean @SuppressWarnings("all") - public ThreadPoolBeanPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent, ThreadPoolOperation threadPoolOperation) { - return new ThreadPoolBeanPostProcessor(properties, httpAgent, threadPoolOperation); + public DynamicThreadPoolPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent, ThreadPoolOperation threadPoolOperation) { + return new DynamicThreadPoolPostProcessor(properties, httpAgent, threadPoolOperation); } @Bean @@ -66,3 +64,5 @@ public class DynamicThreadPoolAutoConfiguration { } } + + diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/HttpClientConfig.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/HttpClientConfig.java index b6925168..76096240 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/HttpClientConfig.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/HttpClientConfig.java @@ -4,7 +4,6 @@ import com.github.dynamic.threadpool.starter.remote.HttpAgent; import com.github.dynamic.threadpool.starter.remote.ServerHttpAgent; import com.github.dynamic.threadpool.starter.toolkit.HttpClientUtil; import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; import okhttp3.OkHttpClient; import org.springframework.context.annotation.Bean; @@ -20,14 +19,8 @@ import java.util.concurrent.TimeUnit; * @author chen.ma * @date 2021/6/10 13:28 */ -@Slf4j public class HttpClientConfig { - /** - * 配置 OkHttpClient Bean - * - * @return - */ @Bean public OkHttpClient okHttpClient() { OkHttpClient.Builder build = new OkHttpClient.Builder(); @@ -44,15 +37,10 @@ public class HttpClientConfig { } @Bean - public HttpAgent httpAgent(DynamicThreadPoolProperties properties, HttpClientUtil httpClientUtil) { + public HttpAgent httpAgent(BootstrapProperties properties, HttpClientUtil httpClientUtil) { return new ServerHttpAgent(properties, httpClientUtil); } - /** - * 支持 Https - * - * @param builder - */ @SneakyThrows private void supportHttps(OkHttpClient.Builder builder) { final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/controller/PoolRunStateController.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/controller/PoolRunStateController.java index 922d0cf1..a5ec3750 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/controller/PoolRunStateController.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/controller/PoolRunStateController.java @@ -22,4 +22,5 @@ public class PoolRunStateController { PoolRunStateInfo poolRunState = ThreadPoolRunStateHandler.getPoolRunState(tpId); return Results.success(poolRunState); } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/CacheData.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/CacheData.java index fd2405b4..ec4a473c 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/CacheData.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/CacheData.java @@ -91,4 +91,5 @@ public class CacheData { public void setTaskId(Integer taskId) { this.taskId = taskId; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ClientWorker.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ClientWorker.java index 38d2a2fa..48a00457 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ClientWorker.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ClientWorker.java @@ -25,7 +25,7 @@ import static com.github.dynamic.threadpool.common.constant.Constants.LINE_SEPAR import static com.github.dynamic.threadpool.common.constant.Constants.WORD_SEPARATOR; /** - * 客户端监听 + * Client Worker. * * @author chen.ma * @date 2021/6/20 18:34 @@ -76,9 +76,6 @@ public class ClientWorker { }, 1L, 10L, TimeUnit.MILLISECONDS); } - /** - * 检查配置信息 - */ public void checkConfigInfo() { int listenerSize = cacheMap.size(); double perTaskConfigSize = 3000D; @@ -92,9 +89,6 @@ public class ClientWorker { } } - /** - * 长轮训任务 - */ class LongPollingRunnable implements Runnable { @SneakyThrows @@ -151,12 +145,6 @@ public class ClientWorker { } } - /** - * 转换入参 - * - * @param cacheDataList - * @return - */ private List checkUpdateDataIds(List cacheDataList) { StringBuilder sb = new StringBuilder(); for (CacheData cacheData : cacheDataList) { @@ -169,12 +157,6 @@ public class ClientWorker { return checkUpdateTpIds(sb.toString()); } - /** - * 检查修改的线程池 ID - * - * @param probeUpdateString - * @return - */ public List checkUpdateTpIds(String probeUpdateString) { Map params = new HashMap(2); params.put(Constants.PROBE_MODIFY_REQUEST, probeUpdateString); @@ -204,15 +186,6 @@ public class ClientWorker { return Collections.emptyList(); } - /** - * 获取服务端配置 - * - * @param namespace - * @param itemId - * @param tpId - * @param readTimeout - * @return - */ public String getServerConfig(String namespace, String itemId, String tpId, long readTimeout) { Map params = new HashMap(3); params.put("namespace", namespace); @@ -229,12 +202,6 @@ public class ClientWorker { return Constants.NULL; } - /** - * Http 响应中获取变更的配置项 - * - * @param response - * @return - */ public List parseUpdateDataIdResponse(String response) { if (StringUtils.isEmpty(response)) { return Collections.emptyList(); @@ -268,14 +235,6 @@ public class ClientWorker { return updateList; } - /** - * CacheData 添加 Listener - * - * @param namespace - * @param itemId - * @param tpId - * @param listeners - */ public void addTenantListeners(String namespace, String itemId, String tpId, List listeners) { CacheData cacheData = addCacheDataIfAbsent(namespace, itemId, tpId); for (Listener listener : listeners) { @@ -283,14 +242,6 @@ public class ClientWorker { } } - /** - * CacheData 不存在则添加 - * - * @param namespace - * @param itemId - * @param tpId - * @return - */ public CacheData addCacheDataIfAbsent(String namespace, String itemId, String tpId) { CacheData cacheData = cacheMap.get(tpId); if (cacheData != null) { @@ -325,4 +276,5 @@ public class ClientWorker { private void setHealthServer(boolean isHealthServer) { this.isHealthServer = isHealthServer; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigAdapter.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigAdapter.java index ec950071..e3f57ee2 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigAdapter.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigAdapter.java @@ -1,7 +1,7 @@ package com.github.dynamic.threadpool.starter.core; /** - * ConfigAdapter. + * Config Adapter. * * @author chen.ma * @date 2021/6/22 21:29 @@ -9,11 +9,12 @@ package com.github.dynamic.threadpool.starter.core; public class ConfigAdapter { /** - * 回调修改线程池配置 + * callback Config. * * @param config */ public void callbackConfig(String config) { ThreadPoolDynamicRefresh.refreshDynamicPool(config); } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigService.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigService.java index 1874b1fb..588db35e 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigService.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ConfigService.java @@ -1,7 +1,7 @@ package com.github.dynamic.threadpool.starter.core; /** - * 配置服务 + * Config Service. * * @author chen.ma * @date 2021/6/21 21:49 @@ -24,4 +24,5 @@ public interface ConfigService { * @return */ String getServerStatus(); + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicTpClient.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolClient.java similarity index 75% rename from dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicTpClient.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolClient.java index 8b79a44d..84b2fde0 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicTpClient.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolClient.java @@ -6,5 +6,5 @@ package com.github.dynamic.threadpool.starter.core; * @author chen.ma * @date 2021/7/13 21:50 */ -public interface DynamicTpClient { +public interface DynamicThreadPoolClient { } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolBeanPostProcessor.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolPostProcessor.java similarity index 91% rename from dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolBeanPostProcessor.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolPostProcessor.java index 11a32d62..3462c47a 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolBeanPostProcessor.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/DynamicThreadPoolPostProcessor.java @@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.common.constant.Constants; import com.github.dynamic.threadpool.common.model.PoolParameterInfo; import com.github.dynamic.threadpool.common.web.base.Result; import com.github.dynamic.threadpool.starter.common.CommonThreadPool; -import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; +import com.github.dynamic.threadpool.starter.config.BootstrapProperties; import com.github.dynamic.threadpool.starter.remote.HttpAgent; import com.github.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum; import com.github.dynamic.threadpool.starter.toolkit.thread.RejectedTypeEnum; @@ -23,22 +23,22 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** - * 线程池包装后置处理器 + * Dynamic ThreadPool Post Processor. * * @author chen.ma * @date 2021/8/2 20:40 */ @Slf4j -public final class ThreadPoolBeanPostProcessor implements BeanPostProcessor { +public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { - private final DynamicThreadPoolProperties properties; + private final BootstrapProperties properties; private final ThreadPoolOperation threadPoolOperation; private final HttpAgent httpAgent; - public ThreadPoolBeanPostProcessor(DynamicThreadPoolProperties properties, HttpAgent httpAgent, - ThreadPoolOperation threadPoolOperation) { + public DynamicThreadPoolPostProcessor(BootstrapProperties properties, HttpAgent httpAgent, + ThreadPoolOperation threadPoolOperation) { this.properties = properties; this.httpAgent = httpAgent; this.threadPoolOperation = threadPoolOperation; diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/GlobalThreadPoolManage.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/GlobalThreadPoolManage.java index 4d769a10..660a819d 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/GlobalThreadPoolManage.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/GlobalThreadPoolManage.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** - * 线程池全局管理 + * Global ThreadPool Manage. * * @author chen.ma * @date 2021/6/20 15:57 @@ -38,4 +38,5 @@ public class GlobalThreadPoolManage { public static void registerPoolParameter(String tpId, PoolParameter poolParameter) { POOL_PARAMETER.put(tpId, poolParameter); } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/InstanceInfo.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/InstanceInfo.java index 464381d3..41db20e8 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/InstanceInfo.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/InstanceInfo.java @@ -1,12 +1,25 @@ package com.github.dynamic.threadpool.starter.core; +import lombok.Getter; +import lombok.Setter; + /** * Instance Info. * * @author chen.ma * @date 2021/7/13 22:10 */ -public class InstanceInfo { +@Getter +@Setter +public class InstanceInfo implements InstanceConfig { + + private static final String UNKNOWN = "unknown"; + + private String appName = UNKNOWN; + + private String hostName; + + private String instanceId; - private String appName; } + diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/Listener.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/Listener.java index b9813b8e..96e1e7c0 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/Listener.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/Listener.java @@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.starter.core; import java.util.concurrent.Executor; /** - * 监听器 + * Listener. * * @author chen.ma * @date 2021/6/22 20:20 @@ -23,4 +23,5 @@ public interface Listener { * @param configInfo */ void receiveConfigInfo(String configInfo); + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolConfigService.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolConfigService.java index df6f191a..941158dc 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolConfigService.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolConfigService.java @@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.starter.remote.HttpAgent; import java.util.Arrays; /** - * 线程池配置服务 + * ThreadPool Config Service. * * @author chen.ma * @date 2021/6/21 21:50 @@ -34,4 +34,5 @@ public class ThreadPoolConfigService implements ConfigService { return "DOWN"; } } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolDynamicRefresh.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolDynamicRefresh.java index 8cff6365..a9e74148 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolDynamicRefresh.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolDynamicRefresh.java @@ -12,7 +12,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** - * 线程池动态刷新 + * ThreadPool Dynamic Refresh. * * @author chen.ma * @date 2021/6/20 15:51 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolOperation.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolOperation.java index 0694745c..78d1680e 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolOperation.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolOperation.java @@ -1,11 +1,11 @@ package com.github.dynamic.threadpool.starter.core; -import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; +import com.github.dynamic.threadpool.starter.config.BootstrapProperties; import java.util.concurrent.Executor; /** - * ThreadPoolOperation. + * ThreadPool Operation. * * @author chen.ma * @date 2021/6/22 20:25 @@ -14,9 +14,9 @@ public class ThreadPoolOperation { private final ConfigService configService; - private final DynamicThreadPoolProperties properties; + private final BootstrapProperties properties; - public ThreadPoolOperation(DynamicThreadPoolProperties properties, ConfigService configService) { + public ThreadPoolOperation(BootstrapProperties properties, ConfigService configService) { this.properties = properties; this.configService = configService; } @@ -38,4 +38,5 @@ public class ThreadPoolOperation { return configListener; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolSubscribeCallback.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolSubscribeCallback.java index 1bfb4642..476f42b3 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolSubscribeCallback.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/core/ThreadPoolSubscribeCallback.java @@ -1,7 +1,7 @@ package com.github.dynamic.threadpool.starter.core; /** - * ThreadPoolSubscribeCallback. + * ThreadPool Subscribe Callback. * * @author chen.ma * @date 2021/6/22 20:26 @@ -14,4 +14,5 @@ public interface ThreadPoolSubscribeCallback { * @param config */ void callback(String config); + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/EnableDynamicThreadPool.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/EnableDynamicThreadPool.java index 2f45076f..b339e163 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/EnableDynamicThreadPool.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/EnableDynamicThreadPool.java @@ -13,7 +13,7 @@ import java.lang.annotation.*; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented -@Import(DynamicThreadPoolMarkerConfiguration.class) +@Import(MarkerConfiguration.class) public @interface EnableDynamicThreadPool { } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/DynamicThreadPoolMarkerConfiguration.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/MarkerConfiguration.java similarity index 89% rename from dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/DynamicThreadPoolMarkerConfiguration.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/MarkerConfiguration.java index 2c2dfd99..90aa2676 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/DynamicThreadPoolMarkerConfiguration.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/enable/MarkerConfiguration.java @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration; * @date 2021/7/8 23:30 */ @Configuration(proxyBeanMethods = false) -public class DynamicThreadPoolMarkerConfiguration { +public class MarkerConfiguration { @Bean public Marker dynamicThreadPoolMarkerBean() { @@ -20,4 +20,5 @@ public class DynamicThreadPoolMarkerConfiguration { public class Marker { } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolBannerHandler.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/DynamicThreadPoolBannerHandler.java similarity index 86% rename from dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolBannerHandler.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/DynamicThreadPoolBannerHandler.java index 60778f14..bc308a79 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolBannerHandler.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/DynamicThreadPoolBannerHandler.java @@ -1,6 +1,6 @@ package com.github.dynamic.threadpool.starter.handler; -import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; +import com.github.dynamic.threadpool.starter.config.BootstrapProperties; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -17,10 +17,10 @@ import org.springframework.boot.ansi.AnsiStyle; */ @Slf4j @RequiredArgsConstructor -public class ThreadPoolBannerHandler implements InitializingBean { +public class DynamicThreadPoolBannerHandler implements InitializingBean { @NonNull - private final DynamicThreadPoolProperties properties; + private final BootstrapProperties properties; private final String DYNAMIC_THREAD_POOL = " :: Dynamic ThreadPool :: "; @@ -53,7 +53,7 @@ public class ThreadPoolBannerHandler implements InitializingBean { } public static String getVersion() { - final Package pkg = ThreadPoolBannerHandler.class.getPackage(); + final Package pkg = DynamicThreadPoolBannerHandler.class.getPackage(); return pkg != null ? pkg.getImplementationVersion() : ""; } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolRunStateHandler.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolRunStateHandler.java index 4eadcbdc..cb36a3fd 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolRunStateHandler.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/handler/ThreadPoolRunStateHandler.java @@ -87,4 +87,5 @@ public class ThreadPoolRunStateHandler { private static String divide(int num1, int num2) { return ((int) (Double.parseDouble(num1 + "") / Double.parseDouble(num2 + "") * 100)) + "%"; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/HttpAgent.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/HttpAgent.java index d9a53575..66f49848 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/HttpAgent.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/HttpAgent.java @@ -75,4 +75,5 @@ public interface HttpAgent { */ Result httpDeleteByConfig(String path, Map headers, Map paramValues, long readTimeoutMs); + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerHttpAgent.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerHttpAgent.java index 9ddb72f4..b873bfcb 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerHttpAgent.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerHttpAgent.java @@ -1,7 +1,7 @@ package com.github.dynamic.threadpool.starter.remote; import com.github.dynamic.threadpool.common.web.base.Result; -import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; +import com.github.dynamic.threadpool.starter.config.BootstrapProperties; import com.github.dynamic.threadpool.starter.toolkit.HttpClientUtil; import java.util.Map; @@ -14,13 +14,13 @@ import java.util.Map; */ public class ServerHttpAgent implements HttpAgent { - private final DynamicThreadPoolProperties dynamicThreadPoolProperties; + private final BootstrapProperties dynamicThreadPoolProperties; private final ServerListManager serverListManager; private final HttpClientUtil httpClientUtil; - public ServerHttpAgent(DynamicThreadPoolProperties properties, HttpClientUtil httpClientUtil) { + public ServerHttpAgent(BootstrapProperties properties, HttpClientUtil httpClientUtil) { this.dynamicThreadPoolProperties = properties; this.httpClientUtil = httpClientUtil; this.serverListManager = new ServerListManager(dynamicThreadPoolProperties); diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerListManager.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerListManager.java index 51605d75..acae5cad 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerListManager.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/remote/ServerListManager.java @@ -1,6 +1,6 @@ package com.github.dynamic.threadpool.starter.remote; -import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties; +import com.github.dynamic.threadpool.starter.config.BootstrapProperties; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; @@ -27,9 +27,9 @@ public class ServerListManager { private Iterator iterator; - private final DynamicThreadPoolProperties properties; + private final BootstrapProperties properties; - public ServerListManager(DynamicThreadPoolProperties dynamicThreadPoolProperties) { + public ServerListManager(BootstrapProperties dynamicThreadPoolProperties) { this.properties = dynamicThreadPoolProperties; serverAddrsStr = properties.getServerAddr(); @@ -122,5 +122,4 @@ public class ServerListManager { } } - } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomBlockingQueue.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomBlockingQueue.java index 50477fc3..e6bfe570 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomBlockingQueue.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomBlockingQueue.java @@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.starter.spi; import java.util.concurrent.BlockingQueue; /** - * 自定义阻塞队列 + * Custom BlockingQueue. * * @author chen.ma * @date 2021/7/11 00:51 @@ -11,14 +11,14 @@ import java.util.concurrent.BlockingQueue; public interface CustomBlockingQueue { /** - * 获取类型 + * Gets the custom blocking queue type. * * @return */ Integer getType(); /** - * 生成阻塞队列 + * Get custom blocking queue. * * @return */ diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomRejectedExecutionHandler.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomRejectedExecutionHandler.java index eb725269..b6ef8e7d 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomRejectedExecutionHandler.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/CustomRejectedExecutionHandler.java @@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.starter.spi; import java.util.concurrent.RejectedExecutionHandler; /** - * 自定义拒绝策略 + * Custom RejectedExecution Handler. * * @author chen.ma * @date 2021/7/10 23:51 @@ -11,14 +11,14 @@ import java.util.concurrent.RejectedExecutionHandler; public interface CustomRejectedExecutionHandler { /** - * 获取类型 + * Get custom reject policy type. * * @return */ Integer getType(); /** - * 生成拒绝策略 + * Get custom reject policy. * * @return */ diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/DynamicTpServiceLoader.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/DynamicTpServiceLoader.java index bd37d410..aa8f5d46 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/DynamicTpServiceLoader.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/spi/DynamicTpServiceLoader.java @@ -43,4 +43,5 @@ public class DynamicTpServiceLoader { throw new ServiceLoaderInstantiationException(clazz, ex); } } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/ArrayUtil.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/ArrayUtil.java index 380c31fe..b8e7aa82 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/ArrayUtil.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/ArrayUtil.java @@ -38,4 +38,5 @@ public class ArrayUtil { } return array.clone(); } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/HttpClientUtil.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/HttpClientUtil.java index 45dffbf0..b728889b 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/HttpClientUtil.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/HttpClientUtil.java @@ -11,7 +11,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; /** - * Http 客户端工具类 + * HttpClient Util. * * @author chen.ma * @date 2021/6/10 13:30 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java index 492f8d15..8aa0339d 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java @@ -9,7 +9,7 @@ import java.util.concurrent.*; import java.util.concurrent.locks.AbstractQueuedSynchronizer; /** - * 抽象线程池模版构建 + * Abstract Build ThreadPool Template. * * @author chen.ma * @date 2021/7/5 21:45 @@ -157,4 +157,5 @@ public class AbstractBuildThreadPoolTemplate { .build(); } } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/Builder.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/Builder.java index 1ec4a8c5..37d30dae 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/Builder.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/Builder.java @@ -3,7 +3,7 @@ package com.github.dynamic.threadpool.starter.toolkit.thread; import java.io.Serializable; /** - * 建造者模式接口定义 + * Builder pattern interface definition. * * @author chen.ma * @date 2021/7/5 21:39 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/FastThreadPoolExecutor.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/FastThreadPoolExecutor.java index 17f2f124..fc086a9b 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/FastThreadPoolExecutor.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/FastThreadPoolExecutor.java @@ -9,9 +9,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** - * 快速执行任务线程池, 参考 Dubbo 线程模型 EagerThreadPoolExecutor - *

- * 配合 {@link TaskQueue} + * Fast ThreadPool Executor. * * @author chen.ma * @date 2021/7/5 21:00 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/QueueTypeEnum.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/QueueTypeEnum.java index e72b598e..2f19b16b 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/QueueTypeEnum.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/QueueTypeEnum.java @@ -9,7 +9,7 @@ import java.util.Optional; import java.util.concurrent.*; /** - * 队列类型枚举 + * Queue Type Enum. * * @author chen.ma * @date 2021/6/25 12:30 @@ -89,4 +89,5 @@ public enum QueueTypeEnum { return blockingQueue; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedPolicies.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedPolicies.java index 90926820..1f4e3f16 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedPolicies.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedPolicies.java @@ -6,7 +6,7 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.RejectedExecutionHandler; /** - * 线程池拒绝策略 + * Rejected Policies. * * @author chen.ma * @date 2021/7/5 21:23 @@ -53,4 +53,5 @@ public class RejectedPolicies { } }; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java index 904a94e8..93fedfbb 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java @@ -11,7 +11,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Stream; /** - * 拒绝策略类型枚举 + * Reject policy type Enum. * * @author chen.ma * @date 2021/7/10 23:16 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ResizableCapacityLinkedBlockIngQueue.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ResizableCapacityLinkedBlockIngQueue.java index 85722bd4..1f5eee88 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ResizableCapacityLinkedBlockIngQueue.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ResizableCapacityLinkedBlockIngQueue.java @@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j; import java.util.concurrent.LinkedBlockingQueue; /** - * 可调整大小的阻塞队列 + * Resizable Capacity LinkedBlockIngQueue. * * @author chen.ma * @date 2021/6/20 14:24 @@ -24,9 +24,10 @@ public class ResizableCapacityLinkedBlockIngQueue extends LinkedBlockingQueue ReflectUtil.setFieldValue(this, "capacity", capacity); } catch (Exception ex) { // ignore - log.error("动态修改阻塞队列大小失败.", ex); + log.error("Dynamic modification of blocking queue size failed.", ex); successFlag = false; } return successFlag; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/TaskQueue.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/TaskQueue.java index 68bbcacf..ef8d1a0a 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/TaskQueue.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/TaskQueue.java @@ -5,9 +5,7 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; /** - * 快速执行任务而阻塞队列, 参考 Dubbo 重写队列 TaskQueue - *

- * 配合 {@link FastThreadPoolExecutor} 使用 + * Task Queue. * * @author chen.ma * @date 2021/7/5 21:00 @@ -45,7 +43,7 @@ public class TaskQueue extends LinkedBlockingQueue public boolean retryOffer(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { if (executor.isShutdown()) { - throw new RejectedExecutionException("执行器已关闭!"); + throw new RejectedExecutionException("Actuator closed!"); } return super.offer(o, timeout, unit); } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadFactoryBuilder.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadFactoryBuilder.java index c0642ca4..5a3247c7 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadFactoryBuilder.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadFactoryBuilder.java @@ -5,7 +5,7 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; /** - * ThreadFactory 创建器 + * ThreadFactory Builder. * * @author chen.ma * @date 2021/7/5 21:53 @@ -152,4 +152,5 @@ public class ThreadFactoryBuilder implements Builder { return thread; }; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java index 1617f6eb..9290526b 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java @@ -7,7 +7,7 @@ import java.math.BigDecimal; import java.util.concurrent.*; /** - * 线程池构造器 + * ThreadPool Builder. * * @author chen.ma * @date 2021/6/28 17:29 @@ -243,4 +243,5 @@ public class ThreadPoolBuilder implements Builder { return initParam; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolExecutorTemplate.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolExecutorTemplate.java index 3426fdfb..2917fe45 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolExecutorTemplate.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolExecutorTemplate.java @@ -5,7 +5,7 @@ import com.github.dynamic.threadpool.starter.toolkit.ArrayUtil; import java.util.concurrent.*; /** - * 线程池创建模版 + * ThreadPool Executor Template. * * @author chen.ma * @date 2021/7/5 21:59 @@ -62,4 +62,5 @@ public class ThreadPoolExecutorTemplate extends ThreadPoolExecutor { } }; } + } diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/DynamicThreadPoolWrap.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/DynamicThreadPoolWrap.java index 01ed12cb..2e32e2a7 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/DynamicThreadPoolWrap.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/DynamicThreadPoolWrap.java @@ -8,7 +8,7 @@ import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; /** - * 线程池包装 + * Dynamic ThreadPool Wrap. * * @author chen.ma * @date 2021/6/20 16:55 diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/ManagerListenerWrap.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/ManagerListenerWrap.java index 034064b2..c0240a7a 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/ManagerListenerWrap.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/wrap/ManagerListenerWrap.java @@ -5,7 +5,7 @@ import lombok.Getter; import lombok.Setter; /** - * 监听包装 + * Manager Listener Wrap. * * @author chen.ma * @date 2021/6/22 17:47 @@ -14,12 +14,13 @@ import lombok.Setter; @Setter public class ManagerListenerWrap { - final Listener listener; + private String lastCallMd5; - String lastCallMd5; + final Listener listener; public ManagerListenerWrap(String md5, Listener listener) { this.lastCallMd5 = md5; this.listener = listener; } + }