From abf25874d8f50409291d20d33f02e439aa47181b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=81=E5=A4=A7=E6=89=8D=E5=AD=90=E4=B9=8B=E9=A6=96?= <48643103+pizihao@users.noreply.github.com> Date: Tue, 6 Sep 2022 08:15:30 +0800 Subject: [PATCH] fix : Redefine the behavior of base and subclasses (#657) --- .../event/AbstractRefreshListener.java | 28 ++++++++++--------- .../AdapterExecutorsRefreshListener.java | 7 ++--- .../DynamicThreadPoolRefreshListener.java | 6 ++-- .../event/WebExecutorRefreshListener.java | 5 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java index 268cd3d7..a42793a5 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java @@ -81,24 +81,26 @@ public abstract class AbstractRefreshListener implements RefreshListener i.check(ipSegment, port)); + .distinct() + .map(IpAndPort::build) + .filter(Objects::nonNull) + .anyMatch(i -> i.check(ipSegment, port)); + } + + /** + * get nodes in new properties + * + * @param properties new properties + * @return nodes in properties + */ + protected String getNodes(M properties) { + return ALL; } /** diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java index 09838838..63eaf876 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java @@ -42,9 +42,8 @@ import static cn.hippo4j.config.springboot.starter.refresher.event.Hippo4jConfig public class AdapterExecutorsRefreshListener extends AbstractRefreshListener { @Override - public boolean match(AdapterExecutorProperties properties) { - String nodes = properties.getNodes(); - return checkArray(nodes); + public String getNodes(AdapterExecutorProperties properties) { + return properties.getNodes(); } @Override @@ -61,7 +60,7 @@ public class AdapterExecutorsRefreshListener extends AbstractRefreshListener { if (Objects.equals(val.mark(), each.getMark())) { val.updateThreadPool(BeanUtil.toBean(each, ThreadPoolAdapterParameter.class)); diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java index ec93577c..1bf61464 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java @@ -21,6 +21,7 @@ import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum; import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue; import cn.hippo4j.common.toolkit.CollectionUtil; +import cn.hippo4j.config.springboot.starter.config.AdapterExecutorProperties; import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties; import cn.hippo4j.config.springboot.starter.config.ExecutorProperties; import cn.hippo4j.config.springboot.starter.notify.CoreNotifyConfigBuilder; @@ -68,9 +69,8 @@ public class DynamicThreadPoolRefreshListener extends AbstractRefreshListener { @Override - public boolean match(WebThreadPoolProperties properties) { - String nodes = properties.getNodes(); - return checkArray(nodes); + public String getNodes(WebThreadPoolProperties properties) { + return properties.getNodes(); } @Override