diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java index 9b372288..06e66d78 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java @@ -78,7 +78,7 @@ public class DefaultPublisher extends Thread implements EventPublisher { private void openEventHandler() { try { int waitTimes = 60; - for (; ; ) { + for (;;) { if (shutdown || hasSubscriber() || waitTimes <= 0) { break; } @@ -89,7 +89,7 @@ public class DefaultPublisher extends Thread implements EventPublisher { } waitTimes--; } - for (; ; ) { + for (;;) { if (shutdown) { break; } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java index a4452ea4..20d9086e 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/ThreadPoolNotifyAlarmHandler.java @@ -85,7 +85,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner List listThreadPoolId = GlobalThreadPoolManage.listThreadPoolId(); listThreadPoolId.forEach(threadPoolId -> { ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); - if (threadPoolNotifyAlarm != null && threadPoolNotifyAlarm.getIsAlarm()) { + if (threadPoolNotifyAlarm != null && threadPoolNotifyAlarm.getAlarm()) { DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId); ThreadPoolExecutor executor = wrapper.getExecutor(); checkPoolCapacityAlarm(threadPoolId, executor); @@ -109,7 +109,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner int queueSize = blockingQueue.size(); int capacity = queueSize + blockingQueue.remainingCapacity(); int divide = CalculateUtil.divide(queueSize, capacity); - boolean isSend = threadPoolNotifyAlarm.getIsAlarm() + boolean isSend = threadPoolNotifyAlarm.getAlarm() && divide > threadPoolNotifyAlarm.getCapacityAlarm(); if (isSend) { AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor); @@ -129,7 +129,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize(); int divide = CalculateUtil.divide(activeCount, maximumPoolSize); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); - boolean isSend = threadPoolNotifyAlarm.getIsAlarm() + boolean isSend = threadPoolNotifyAlarm.getAlarm() && divide > threadPoolNotifyAlarm.getActiveAlarm(); if (isSend) { AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor); @@ -145,7 +145,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner */ public void checkPoolRejectedAlarm(String threadPoolId) { ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); - if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getIsAlarm()) { + if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) { return; } ThreadPoolExecutor threadPoolExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor(); @@ -176,7 +176,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner */ public void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor) { ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); - if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getIsAlarm()) { + if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) { return; } if (threadPoolExecutor instanceof DynamicThreadPoolExecutor) { diff --git a/hippo4j-message/src/main/java/cn/hippo4j/message/service/ThreadPoolNotifyAlarm.java b/hippo4j-message/src/main/java/cn/hippo4j/message/service/ThreadPoolNotifyAlarm.java index 15c37b16..00ae2c63 100644 --- a/hippo4j-message/src/main/java/cn/hippo4j/message/service/ThreadPoolNotifyAlarm.java +++ b/hippo4j-message/src/main/java/cn/hippo4j/message/service/ThreadPoolNotifyAlarm.java @@ -33,10 +33,10 @@ import java.util.Map; public class ThreadPoolNotifyAlarm { /** - * Is alarm + * Whether to enable thread pool running alarm */ @NonNull - private Boolean isAlarm; + private Boolean alarm; /** * Active alarm diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java index 0aba2ac6..b829885e 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/notify/CoreNotifyConfigBuilder.java @@ -56,7 +56,7 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder { log.warn("Failed to build notify, executors configuration is empty."); return resultMap; } - List actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getIsAlarm()).orElse(false)).collect(Collectors.toList()); + List actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getAlarm()).orElse(false)).collect(Collectors.toList()); if (!globalAlarm && CollectionUtil.isEmpty(actual)) { return resultMap; } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java index 1c736094..1f7cd9ab 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/ZookeeperRefresherHandler.java @@ -110,7 +110,7 @@ public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefr public void registerNotifyAlarmManage() { bootstrapCoreProperties.getExecutors().forEach(executorProperties -> { ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm( - executorProperties.getNotify().getIsAlarm(), + executorProperties.getNotify().getAlarm(), executorProperties.getNotify().getCapacityAlarm(), executorProperties.getNotify().getActiveAlarm()); threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval()); diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java index 158ce965..7b27ca13 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/refresher/event/ExecutorsListener.java @@ -165,14 +165,14 @@ public class ExecutorsListener implements ApplicationListener each.getIsAlarm()).orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true); + .map(each -> each.getAlarm()).orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true); int activeAlarm = Optional.ofNullable(notify) .map(each -> each.getActiveAlarm()).orElseGet(() -> bootstrapCoreProperties.getActiveAlarm() != null ? bootstrapCoreProperties.getActiveAlarm() : 80); int capacityAlarm = Optional.ofNullable(notify)