diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/notify/DynamicThreadPoolRegisterCoreNotifyParameter.java b/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/notify/DynamicThreadPoolRegisterCoreNotifyParameter.java index b4da1736..fc61c5cd 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/notify/DynamicThreadPoolRegisterCoreNotifyParameter.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/model/register/notify/DynamicThreadPoolRegisterCoreNotifyParameter.java @@ -28,21 +28,6 @@ import lombok.*; @AllArgsConstructor public class DynamicThreadPoolRegisterCoreNotifyParameter { - /** - * Whether to enable thread pool running alarm - */ - private Boolean alarm = Boolean.TRUE; - - /** - * Active alarm - */ - private Integer activeAlarm; - - /** - * Capacity alarm - */ - private Integer capacityAlarm; - /** * Interval */ 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 ffab5101..7a251e6d 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 @@ -180,6 +180,7 @@ public class ConfigServiceImpl implements ConfigService { configAllInfo.setTenantId(registerWrapper.getTenantId()); configAllInfo.setItemId(registerWrapper.getItemId()); configAllInfo.setTpId(registerParameter.getThreadPoolId()); + configAllInfo.setLivenessAlarm(registerParameter.getActiveAlarm()); configAllInfo.setAllowCoreThreadTimeOut(registerParameter.getAllowCoreThreadTimeOut()); return configAllInfo; } diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java index 54105fbc..ff05b814 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RegisterDynamicThreadPoolTest.java @@ -38,37 +38,36 @@ public class RegisterDynamicThreadPoolTest { public static ThreadPoolExecutor registerDynamicThreadPool(String threadPoolId) { DynamicThreadPoolRegisterParameter parameterInfo = DynamicThreadPoolRegisterParameter.builder() - .corePoolSize(3) - .maximumPoolSize(10) - .queueType(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.type) - .capacity(110) + .corePoolSize(1) + .maximumPoolSize(2) + .queueType(QueueTypeEnum.LINKED_BLOCKING_QUEUE.type) + .capacity(1024) // TimeUnit.SECONDS - .keepAliveTime(100L) + .keepAliveTime(1024L) // TimeUnit.MILLISECONDS - .executeTimeOut(800L) - .rejectedType(RejectedTypeEnum.ABORT_POLICY.type) + .executeTimeOut(1024L) + .rejectedType(RejectedTypeEnum.DISCARD_POLICY.type) .isAlarm(true) - .capacityAlarm(80) - .activeAlarm(80) + .allowCoreThreadTimeOut(false) + .capacityAlarm(90) + .activeAlarm(90) .threadPoolId(threadPoolId) .threadNamePrefix(threadPoolId) - .allowCoreThreadTimeOut(true) .build(); // Core mode and server mode, you can choose one of them. DynamicThreadPoolRegisterCoreNotifyParameter coreNotifyParameter = DynamicThreadPoolRegisterCoreNotifyParameter.builder() - .activeAlarm(80) - .capacityAlarm(80) .receives("chen.ma") - .alarm(true) .interval(5) .build(); DynamicThreadPoolRegisterServerNotifyParameter serverNotifyParameter = DynamicThreadPoolRegisterServerNotifyParameter.builder() .platform(NotifyPlatformEnum.WECHAT.name()) .accessToken("7487d0a0-20ec-40ab-b67b-ce68db406b37") - .interval(5) + .interval(10) .receives("chen.ma") .build(); DynamicThreadPoolRegisterWrapper registerWrapper = DynamicThreadPoolRegisterWrapper.builder() + .updateIfExists(true) + .notifyUpdateIfExists(true) .dynamicThreadPoolRegisterParameter(parameterInfo) .dynamicThreadPoolRegisterCoreNotifyParameter(coreNotifyParameter) .dynamicThreadPoolRegisterServerNotifyParameter(serverNotifyParameter) diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RunStateHandlerTest.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RunStateHandlerTest.java index c4791508..b6498fbc 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RunStateHandlerTest.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/inittest/RunStateHandlerTest.java @@ -64,7 +64,7 @@ public class RunStateHandlerTest { runTask(messageConsumeTtlDynamicThreadPool); runTask(messageProduceDynamicThreadPool); // Dynamically register thread pool - ThreadPoolExecutor registerDynamicThreadPool = RegisterDynamicThreadPoolTest.registerDynamicThreadPool("register-dynamic-thread-pool"); + ThreadPoolExecutor registerDynamicThreadPool = RegisterDynamicThreadPoolTest.registerDynamicThreadPool("auto-register-dynamic-thread-pool"); runTask(registerDynamicThreadPool); }