From aa19960582492cacb50178b2800d36a25afdc5c6 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sun, 18 Jul 2021 22:49:05 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BA=BF=E7=A8=8B=E6=B1=A0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/ThreadPoolRunStateHandler.java | 2 +- .../core/registry/DiscoveryClient.java | 51 +++++++++++++++++++ .../core/registry/DynamicTpClient.java | 10 ++++ .../starter/core/registry/InstanceInfo.java | 12 +++++ .../threadpool/starter/remote/HttpAgent.java | 2 +- .../AbstractBuildThreadPoolTemplate.java | 3 +- .../thread}/CustomThreadPoolExecutor.java | 4 +- 7 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DiscoveryClient.java create mode 100644 dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DynamicTpClient.java create mode 100644 dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/InstanceInfo.java rename dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/{wrap => toolkit/thread}/CustomThreadPoolExecutor.java (99%) diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunStateHandler.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunStateHandler.java index 4867ac6e..55b54e57 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunStateHandler.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunStateHandler.java @@ -1,7 +1,7 @@ package io.dynamic.threadpool.starter.core; import io.dynamic.threadpool.common.model.PoolRunStateInfo; -import io.dynamic.threadpool.starter.wrap.CustomThreadPoolExecutor; +import io.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor; import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; import java.net.InetAddress; diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DiscoveryClient.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DiscoveryClient.java new file mode 100644 index 00000000..5becae72 --- /dev/null +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DiscoveryClient.java @@ -0,0 +1,51 @@ +package io.dynamic.threadpool.starter.core.registry; + +/** + * Discovery Client. + * + * @author chen.ma + * @date 2021/7/13 21:51 + */ +public class DiscoveryClient { + + private InstanceInfo instanceInfo; + + /** + * 初始化所有计划任务 + */ + private void initScheduledTasks() { + + } + + /** + * 注册实例到服务端 + * + * @return + */ + boolean register() { + + return true; + } + + + /** + * 与 Server 端保持心跳续约 + */ + public class HeartbeatThread implements Runnable { + + @Override + public void run() { + + } + } + + /** + * 心跳续约 + * + * @return + */ + boolean renew() { + + return true; + } +} diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DynamicTpClient.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DynamicTpClient.java new file mode 100644 index 00000000..e1a30b11 --- /dev/null +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/DynamicTpClient.java @@ -0,0 +1,10 @@ +package io.dynamic.threadpool.starter.core.registry; + +/** + * Dynamic Tp Client. + * + * @author chen.ma + * @date 2021/7/13 21:50 + */ +public interface DynamicTpClient { +} diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/InstanceInfo.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/InstanceInfo.java new file mode 100644 index 00000000..9ec7a05a --- /dev/null +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/registry/InstanceInfo.java @@ -0,0 +1,12 @@ +package io.dynamic.threadpool.starter.core.registry; + +/** + * Instance Info. + * + * @author chen.ma + * @date 2021/7/13 22:10 + */ +public class InstanceInfo { + + private String appName; +} diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/remote/HttpAgent.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/remote/HttpAgent.java index 8aa1e87e..91c22a33 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/remote/HttpAgent.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/remote/HttpAgent.java @@ -13,7 +13,7 @@ import java.util.Map; public interface HttpAgent { /** - * 开始获取 NacosIp 集合 + * 开始获取服务集合 */ void start(); diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java index 4e7bce27..9f7cde20 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/AbstractBuildThreadPoolTemplate.java @@ -1,7 +1,6 @@ package io.dynamic.threadpool.starter.toolkit.thread; import io.dynamic.threadpool.common.toolkit.Assert; -import io.dynamic.threadpool.starter.wrap.CustomThreadPoolExecutor; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; @@ -158,4 +157,4 @@ public class AbstractBuildThreadPoolTemplate { .build(); } } -} \ No newline at end of file +} diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/wrap/CustomThreadPoolExecutor.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/CustomThreadPoolExecutor.java similarity index 99% rename from dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/wrap/CustomThreadPoolExecutor.java rename to dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/CustomThreadPoolExecutor.java index f213cb5f..62d3783d 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/wrap/CustomThreadPoolExecutor.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/CustomThreadPoolExecutor.java @@ -1,4 +1,4 @@ -package io.dynamic.threadpool.starter.wrap; +package io.dynamic.threadpool.starter.toolkit.thread; import lombok.Getter; @@ -19,7 +19,7 @@ import java.util.concurrent.locks.ReentrantLock; * @date 2021/7/8 21:47 */ @Getter -public final class CustomThreadPoolExecutor extends ThreadPoolExecutor { +public final class CustomThreadPoolExecutor extends ThreadPoolExecutorTemplate { private final AtomicInteger regectCount = new AtomicInteger(); private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));