This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 350abbdda1a Refactor RuleConfigurationChangedHandler (#34888)
350abbdda1a is described below
commit 350abbdda1a32da7d378f08392b42a17f6e503ac
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Mar 5 20:31:05 2025 +0800
Refactor RuleConfigurationChangedHandler (#34888)
---
.../handler/database/rule/RuleConfigurationChangedHandler.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandler.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandler.java
index b20337b4264..e20f25342ab 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandler.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandler.java
@@ -23,10 +23,13 @@ import
org.apache.shardingsphere.mode.manager.ContextManager;
import
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.database.DatabaseChangedHandler;
import
org.apache.shardingsphere.mode.metadata.changed.RuleItemChangedNodePathBuilder;
import
org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathPattern;
+import
org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleItem;
import
org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleNodePath;
import
org.apache.shardingsphere.mode.node.path.type.version.VersionNodePathParser;
import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Optional;
/**
@@ -41,7 +44,10 @@ public final class RuleConfigurationChangedHandler
implements DatabaseChangedHan
@Override
public boolean isSubscribed(final String databaseName, final
DataChangedEvent event) {
- return new VersionNodePathParser(new
DatabaseRuleNodePath(databaseName, NodePathPattern.IDENTIFIER,
null)).isActiveVersionPath(event.getKey());
+ Collection<DatabaseRuleNodePath> databaseRuleNodePaths = Arrays.asList(
+ new DatabaseRuleNodePath(databaseName,
NodePathPattern.QUALIFIED_IDENTIFIER, new
DatabaseRuleItem(NodePathPattern.IDENTIFIER)),
+ new DatabaseRuleNodePath(databaseName,
NodePathPattern.IDENTIFIER, new DatabaseRuleItem(NodePathPattern.IDENTIFIER,
NodePathPattern.QUALIFIED_IDENTIFIER)));
+ return databaseRuleNodePaths.stream().anyMatch(each -> new
VersionNodePathParser(each).isActiveVersionPath(event.getKey()));
}
@Override