From 0613a92cdad39312dde5b580be33cf8e8845824c Mon Sep 17 00:00:00 2001 From: hezijian <510310243@qq.com> Date: Fri, 17 Mar 2023 14:02:07 +0800 Subject: [PATCH] fix:add log and adjust details --- .../starter/config/DynamicThreadPoolAutoConfiguration.java | 3 +-- .../cn/hippo4j/springboot/starter/core/ClientShutdown.java | 3 +++ .../cn/hippo4j/springboot/starter/core/DiscoveryClient.java | 3 +-- .../hippo4j/springboot/starter/remote/ServerHttpAgent.java | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index 27b05996..ce59d27a 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -63,7 +63,6 @@ import cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService; import cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor; import cn.hippo4j.springboot.starter.support.ThreadPoolPluginRegisterPostProcessor; import lombok.AllArgsConstructor; -import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -250,7 +249,7 @@ public class DynamicThreadPoolAutoConfiguration { } @Bean - public ClientShutdown clientShutdown() { + public ClientShutdown hippo4jClientShutdown() { return new ClientShutdown(); } } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientShutdown.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientShutdown.java index 9837b816..d22c1697 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientShutdown.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientShutdown.java @@ -21,6 +21,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import lombok.Getter; +/** + * Client Shutdown + */ public class ClientShutdown { @Getter diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DiscoveryClient.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DiscoveryClient.java index 1cd6fe63..fe619f60 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DiscoveryClient.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DiscoveryClient.java @@ -115,8 +115,7 @@ public class DiscoveryClient implements DisposableBean { } private void prepareDestroy() throws InterruptedException { - // close scheduled - this.scheduler.shutdown(); + this.scheduler.shutdownNow(); // try to make sure the ClientWorker is closed first ApplicationContextHolder.getBean(ClientShutdown.class).prepareDestroy(); } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/ServerHttpAgent.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/ServerHttpAgent.java index feb5044b..5c41aced 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/ServerHttpAgent.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/ServerHttpAgent.java @@ -32,10 +32,12 @@ import java.util.Map; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; /** * Server http agent. */ +@Slf4j public class ServerHttpAgent implements HttpAgent { private final BootstrapProperties dynamicThreadPoolProperties; @@ -114,7 +116,7 @@ public class ServerHttpAgent implements HttpAgent { isHealthStatus(); injectSecurityInfo(paramValues); if (isPrepareClose()) { - return null; + return new Result(); } return HttpUtil.post(buildUrl(path), headers, paramValues, readTimeoutMs, Result.class); } @@ -141,6 +143,7 @@ public class ServerHttpAgent implements HttpAgent { } if (clientShutdown.isPrepareClose()) { clientShutdown.countDown(); + log.info("client prepare shutdown"); return true; } return false;