From 02b7c224c79ff8e0678bb78aef44c8ab561d133b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=E5=93=A5?= Date: Thu, 11 Aug 2022 08:32:12 +0800 Subject: [PATCH 1/2] Migration code package location (#520) --- .../starter/config/DynamicThreadPoolAutoConfiguration.java | 1 + .../java/cn/hippo4j/springboot/starter/core/ClientWorker.java | 2 +- .../{core => support}/DynamicThreadPoolConfigService.java | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) rename hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/{core => support}/DynamicThreadPoolConfigService.java (96%) 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 0213fc88..2cb39f27 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 @@ -47,6 +47,7 @@ import cn.hippo4j.springboot.starter.notify.ServerNotifyConfigBuilder; import cn.hippo4j.springboot.starter.remote.HttpAgent; import cn.hippo4j.springboot.starter.remote.HttpScheduledHealthCheck; import cn.hippo4j.springboot.starter.remote.ServerHealthCheck; +import cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService; import cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor; import lombok.AllArgsConstructor; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java index 8e0deebe..2e945da9 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java @@ -252,7 +252,7 @@ public class ClientWorker { this.serverHealthCheck.setHealthStatus(isHealthServer); } - protected void notifyApplicationComplete() { + public void notifyApplicationComplete() { awaitApplicationComplete.countDown(); } } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolConfigService.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java similarity index 96% rename from hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolConfigService.java rename to hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java index 5dc69414..22898ab5 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/DynamicThreadPoolConfigService.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolConfigService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package cn.hippo4j.springboot.starter.core; +package cn.hippo4j.springboot.starter.support; import cn.hippo4j.common.model.ThreadPoolParameterInfo; import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterParameter; @@ -31,6 +31,8 @@ import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.support.service.AbstractDynamicThreadPoolService; import cn.hippo4j.message.service.ThreadPoolNotifyAlarm; import cn.hippo4j.springboot.starter.config.BootstrapProperties; +import cn.hippo4j.springboot.starter.core.ClientWorker; +import cn.hippo4j.springboot.starter.core.DynamicThreadPoolSubscribeConfig; import cn.hippo4j.springboot.starter.event.ApplicationCompleteEvent; import cn.hippo4j.springboot.starter.remote.HttpAgent; import lombok.RequiredArgsConstructor; From 2d508c0dd232c7d1a760741a791d85d52d599140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=E5=93=A5?= Date: Thu, 11 Aug 2022 08:37:51 +0800 Subject: [PATCH 2/2] Add condition to update if notification exists (#521) --- .../model/register/DynamicThreadPoolRegisterWrapper.java | 7 ++++++- .../java/cn/hippo4j/config/service/biz/NotifyService.java | 3 ++- .../hippo4j/config/service/biz/impl/ConfigServiceImpl.java | 7 ++----- .../hippo4j/config/service/biz/impl/NotifyServiceImpl.java | 5 ++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/DynamicThreadPoolRegisterWrapper.java b/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/DynamicThreadPoolRegisterWrapper.java index 1df939c0..a543223e 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/DynamicThreadPoolRegisterWrapper.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/DynamicThreadPoolRegisterWrapper.java @@ -55,7 +55,12 @@ public class DynamicThreadPoolRegisterWrapper { /** * Update if exists */ - private Boolean updateIfExists = Boolean.TRUE; + private Boolean updateIfExists = Boolean.FALSE; + + /** + * Notify update if exists + */ + private Boolean notifyUpdateIfExists = Boolean.FALSE; /** * Dynamic thread-pool server notify parameter diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/NotifyService.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/NotifyService.java index a0bfc412..fbad36ef 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/NotifyService.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/NotifyService.java @@ -63,9 +63,10 @@ public interface NotifyService { /** * Save or update. * + * @param notifyUpdateIfExists * @param reqDTO */ - void saveOrUpdate(NotifyReqDTO reqDTO); + void saveOrUpdate(boolean notifyUpdateIfExists, NotifyReqDTO reqDTO); /** * Delete. diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java index 04034503..ffab5101 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java @@ -27,10 +27,7 @@ import cn.hippo4j.common.web.exception.ServiceException; import cn.hippo4j.config.event.LocalDataChangeEvent; import cn.hippo4j.config.mapper.ConfigInfoMapper; import cn.hippo4j.config.mapper.ConfigInstanceMapper; -import cn.hippo4j.config.model.ConfigAllInfo; -import cn.hippo4j.config.model.ConfigInfoBase; -import cn.hippo4j.config.model.ConfigInstanceInfo; -import cn.hippo4j.config.model.LogRecordInfo; +import cn.hippo4j.config.model.*; import cn.hippo4j.config.model.biz.notify.NotifyReqDTO; import cn.hippo4j.config.service.ConfigCacheService; import cn.hippo4j.config.service.ConfigChangePublisher; @@ -172,7 +169,7 @@ public class ConfigServiceImpl implements ConfigService { } else { notifyReqDTO.setConfigType(true); } - notifyService.saveOrUpdate(notifyReqDTO); + notifyService.saveOrUpdate(registerWrapper.getNotifyUpdateIfExists(), notifyReqDTO); }); } } diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/NotifyServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/NotifyServiceImpl.java index 35c886ee..0a597c5d 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/NotifyServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/NotifyServiceImpl.java @@ -120,11 +120,14 @@ public class NotifyServiceImpl implements NotifyService { } @Override - public void saveOrUpdate(NotifyReqDTO reqDTO) { + public void saveOrUpdate(boolean notifyUpdateIfExists, NotifyReqDTO reqDTO) { try { existNotify(reqDTO.getType(), reqDTO); save(reqDTO); } catch (Exception ignored) { + if (!notifyUpdateIfExists) { + return; + } LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(NotifyInfo.class) .eq(NotifyInfo::getTenantId, reqDTO.getTenantId()) .eq(NotifyInfo::getItemId, reqDTO.getItemId())