fix : Redefine the behavior of base and subclasses (#657)

pull/661/head
十大才子之首 2 years ago committed by GitHub
parent a92656ecca
commit abf25874d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,24 +81,26 @@ public abstract class AbstractRefreshListener<M> implements RefreshListener<Hipp
*/ */
@Override @Override
public boolean match(M properties) { public boolean match(M properties) {
return false; String nodes = getNodes(properties);
}
/**
* check all
*
* @param nodes nodes
*/
protected boolean checkArray(String nodes) {
if (StringUtil.isEmpty(nodes) || ALL.equals(nodes)) { if (StringUtil.isEmpty(nodes) || ALL.equals(nodes)) {
return true; return true;
} }
String[] splitNodes = nodes.split(SEPARATOR); String[] splitNodes = nodes.split(SEPARATOR);
return Arrays.stream(splitNodes) return Arrays.stream(splitNodes)
.distinct() .distinct()
.map(IpAndPort::build) .map(IpAndPort::build)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.anyMatch(i -> i.check(ipSegment, port)); .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;
} }
/** /**

@ -42,9 +42,8 @@ import static cn.hippo4j.config.springboot.starter.refresher.event.Hippo4jConfig
public class AdapterExecutorsRefreshListener extends AbstractRefreshListener<AdapterExecutorProperties> { public class AdapterExecutorsRefreshListener extends AbstractRefreshListener<AdapterExecutorProperties> {
@Override @Override
public boolean match(AdapterExecutorProperties properties) { public String getNodes(AdapterExecutorProperties properties) {
String nodes = properties.getNodes(); return properties.getNodes();
return checkArray(nodes);
} }
@Override @Override
@ -61,7 +60,7 @@ public class AdapterExecutorsRefreshListener extends AbstractRefreshListener<Ada
continue; continue;
} }
if (!Objects.equals(adapterExecutorProperties.getCorePoolSize(), each.getCorePoolSize()) if (!Objects.equals(adapterExecutorProperties.getCorePoolSize(), each.getCorePoolSize())
|| !Objects.equals(adapterExecutorProperties.getMaximumPoolSize(), each.getMaximumPoolSize())) { || !Objects.equals(adapterExecutorProperties.getMaximumPoolSize(), each.getMaximumPoolSize())) {
threadPoolAdapterMap.forEach((key, val) -> { threadPoolAdapterMap.forEach((key, val) -> {
if (Objects.equals(val.mark(), each.getMark())) { if (Objects.equals(val.mark(), each.getMark())) {
val.updateThreadPool(BeanUtil.toBean(each, ThreadPoolAdapterParameter.class)); val.updateThreadPool(BeanUtil.toBean(each, ThreadPoolAdapterParameter.class));

@ -21,6 +21,7 @@ import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum; import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue; import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
import cn.hippo4j.common.toolkit.CollectionUtil; 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.BootstrapConfigProperties;
import cn.hippo4j.config.springboot.starter.config.ExecutorProperties; import cn.hippo4j.config.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.config.springboot.starter.notify.CoreNotifyConfigBuilder; import cn.hippo4j.config.springboot.starter.notify.CoreNotifyConfigBuilder;
@ -68,9 +69,8 @@ public class DynamicThreadPoolRefreshListener extends AbstractRefreshListener<Ex
private final Hippo4jBaseSendMessageService hippo4jBaseSendMessageService; private final Hippo4jBaseSendMessageService hippo4jBaseSendMessageService;
@Override @Override
public boolean match(ExecutorProperties properties) { public String getNodes(ExecutorProperties properties) {
String nodes = properties.getNodes(); return properties.getNodes();
return checkArray(nodes);
} }
@Override @Override

@ -39,9 +39,8 @@ import static cn.hippo4j.config.springboot.starter.refresher.event.Hippo4jConfig
public class WebExecutorRefreshListener extends AbstractRefreshListener<WebThreadPoolProperties> { public class WebExecutorRefreshListener extends AbstractRefreshListener<WebThreadPoolProperties> {
@Override @Override
public boolean match(WebThreadPoolProperties properties) { public String getNodes(WebThreadPoolProperties properties) {
String nodes = properties.getNodes(); return properties.getNodes();
return checkArray(nodes);
} }
@Override @Override

Loading…
Cancel
Save