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 aaab6b887e0 Refactor StorageUnitNodePath and StorageNodeNodePath 
(#34755)
aaab6b887e0 is described below

commit aaab6b887e02a1f6c5b9a035eb61c9e5127a7d38
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Feb 23 12:55:05 2025 +0800

    Refactor StorageUnitNodePath and StorageNodeNodePath (#34755)
    
    * Refactor StorageUnitNodePath and StorageNodeNodePath
    
    * Refactor StorageUnitNodePath and StorageNodeNodePath
---
 .../mode/node/path/NodePathSearcher.java           |  6 +--
 .../metadata/storage/DataSourceNodePathParser.java | 44 ----------------
 .../path/metadata/storage/StorageNodeNodePath.java | 15 ++++++
 .../storage/StorageNodeNodePathParser.java         | 61 ----------------------
 .../path/metadata/storage/StorageUnitNodePath.java | 24 +++++++++
 .../storage/StorageUnitNodePathParser.java         | 61 ----------------------
 .../storage/DataSourceNodePathParserTest.java      | 30 -----------
 .../storage/StorageNodeNodePathParserTest.java     | 42 ---------------
 .../metadata/storage/StorageNodeNodePathTest.java  | 10 ++++
 .../storage/StorageUnitNodePathParserTest.java     | 42 ---------------
 .../metadata/storage/StorageUnitNodePathTest.java  | 20 +++++++
 .../database/metadata/MetaDataChangedHandler.java  | 15 +++---
 12 files changed, 79 insertions(+), 291 deletions(-)

diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathSearcher.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathSearcher.java
index f9f37b5e1c7..7d18b634878 100644
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathSearcher.java
+++ 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathSearcher.java
@@ -62,10 +62,10 @@ public final class NodePathSearcher {
     /**
      * Get version node path parser.
      *
-     * @param nodePathCriteria node path criteria
+     * @param searchExample search example
      * @return version node path parser
      */
-    public static VersionNodePathParser getVersion(final NodePath 
nodePathCriteria) {
-        return new 
VersionNodePathParser(NodePathGenerator.toPath(nodePathCriteria, false));
+    public static VersionNodePathParser getVersion(final NodePath 
searchExample) {
+        return new 
VersionNodePathParser(NodePathGenerator.toPath(searchExample, false));
     }
 }
diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParser.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParser.java
deleted file mode 100644
index be94714d35e..00000000000
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParser.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-import java.util.regex.Pattern;
-
-/**
- * Data source node path parser.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DataSourceNodePathParser {
-    
-    private static final Pattern PATTERN = 
Pattern.compile(NodePathGenerator.toPath(new 
StorageUnitNodePath(NodePathPattern.IDENTIFIER, null), true) + "?", 
Pattern.CASE_INSENSITIVE);
-    
-    /**
-     * Is data source path.
-     *
-     * @param path path
-     * @return is data source path or not
-     */
-    public static boolean isDataSourcePath(final String path) {
-        return PATTERN.matcher(path).find();
-    }
-}
diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePath.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePath.java
index 875a0e08455..8c020ee8cf7 100644
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePath.java
+++ 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePath.java
@@ -21,6 +21,8 @@ import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.mode.node.path.NodePath;
 import org.apache.shardingsphere.mode.node.path.NodePathEntity;
+import org.apache.shardingsphere.mode.node.path.NodePathPattern;
+import org.apache.shardingsphere.mode.node.path.NodePathSearchCriteria;
 
 /**
  * Storage node node path.
@@ -33,4 +35,17 @@ public final class StorageNodeNodePath implements NodePath {
     private final String databaseName;
     
     private final String storageNodeName;
+    
+    public StorageNodeNodePath() {
+        this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
+    }
+    
+    /**
+     * Create storage node search criteria.
+     *
+     * @return created search criteria
+     */
+    public static NodePathSearchCriteria createStorageNodeSearchCriteria() {
+        return new NodePathSearchCriteria(new StorageNodeNodePath(), false, 
false, 2);
+    }
 }
diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParser.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParser.java
deleted file mode 100644
index 838bacb0a4b..00000000000
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParser.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Storage node node path parser.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class StorageNodeNodePathParser {
-    
-    private static final Pattern PATTERN = Pattern.compile(
-            NodePathGenerator.toPath(new 
StorageNodeNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), 
false) + "$", Pattern.CASE_INSENSITIVE);
-    
-    private static final VersionNodePathParser VERSION_PARSER = new 
VersionNodePathParser(
-            NodePathGenerator.toPath(new 
StorageNodeNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), 
false));
-    
-    /**
-     * Find storage node name.
-     *
-     * @param path path
-     * @return found storage node name
-     */
-    public static Optional<String> findStorageNodeName(final String path) {
-        Matcher matcher = PATTERN.matcher(path);
-        return matcher.find() ? Optional.of(matcher.group(2)) : 
Optional.empty();
-    }
-    
-    /**
-     * Get storage node version node path parser.
-     *
-     * @return storage node version node path parser
-     */
-    public static VersionNodePathParser getVersion() {
-        return VERSION_PARSER;
-    }
-}
diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePath.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePath.java
index e0b6779469c..d8128641728 100644
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePath.java
+++ 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePath.java
@@ -21,6 +21,8 @@ import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.mode.node.path.NodePath;
 import org.apache.shardingsphere.mode.node.path.NodePathEntity;
+import org.apache.shardingsphere.mode.node.path.NodePathPattern;
+import org.apache.shardingsphere.mode.node.path.NodePathSearchCriteria;
 
 /**
  * Storage unit node path.
@@ -33,4 +35,26 @@ public final class StorageUnitNodePath implements NodePath {
     private final String databaseName;
     
     private final String storageUnitName;
+    
+    public StorageUnitNodePath() {
+        this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
+    }
+    
+    /**
+     * Create data source search criteria.
+     *
+     * @return created search criteria
+     */
+    public static NodePathSearchCriteria createDataSourceSearchCriteria() {
+        return new NodePathSearchCriteria(new 
StorageUnitNodePath(NodePathPattern.IDENTIFIER, null), true, true, 1);
+    }
+    
+    /**
+     * Create storage unit search criteria.
+     *
+     * @return created search criteria
+     */
+    public static NodePathSearchCriteria createStorageUnitSearchCriteria() {
+        return new NodePathSearchCriteria(new StorageUnitNodePath(), false, 
false, 2);
+    }
 }
diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParser.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParser.java
deleted file mode 100644
index 33bfa386ed3..00000000000
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParser.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Storage unit node path parser.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class StorageUnitNodePathParser {
-    
-    private static final Pattern PATTERN = Pattern.compile(
-            NodePathGenerator.toPath(new 
StorageUnitNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), 
false) + "$", Pattern.CASE_INSENSITIVE);
-    
-    private static final VersionNodePathParser VERSION_PARSER = new 
VersionNodePathParser(
-            NodePathGenerator.toPath(new 
StorageUnitNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), 
false));
-    
-    /**
-     * Find storage unit name.
-     *
-     * @param path path
-     * @return found storage unit name
-     */
-    public static Optional<String> findStorageUnitName(final String path) {
-        Matcher matcher = PATTERN.matcher(path);
-        return matcher.find() ? Optional.of(matcher.group(2)) : 
Optional.empty();
-    }
-    
-    /**
-     * Get storage unit version unit path parser.
-     *
-     * @return storage unit version node path parser
-     */
-    public static VersionNodePathParser getVersion() {
-        return VERSION_PARSER;
-    }
-}
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParserTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParserTest.java
deleted file mode 100644
index 584c99771de..00000000000
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathParserTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class DataSourceNodePathParserTest {
-    
-    @Test
-    void assertIsDataSourcePath() {
-        
assertTrue(DataSourceNodePathParser.isDataSourcePath("/metadata/foo_db/data_sources/foo_ds"));
-    }
-}
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParserTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParserTest.java
deleted file mode 100644
index 9007ae98862..00000000000
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathParserTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class StorageNodeNodePathParserTest {
-    
-    @Test
-    void assertFindStorageNodeName() {
-        Optional<String> actual = 
StorageNodeNodePathParser.findStorageNodeName("/metadata/foo_db/data_sources/nodes/foo_ds");
-        assertTrue(actual.isPresent());
-        assertThat(actual.get(), is("foo_ds"));
-    }
-    
-    @Test
-    void assertFindStorageNodeNameIfNotFound() {
-        
assertFalse(StorageNodeNodePathParser.findStorageNodeName("/xxx/foo_db/data_sources/nodes/foo_ds").isPresent());
-    }
-}
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathTest.java
index 3cb1097eb78..f835bea9352 100644
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathTest.java
+++ 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageNodeNodePathTest.java
@@ -18,10 +18,14 @@
 package org.apache.shardingsphere.mode.node.path.metadata.storage;
 
 import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NodePathSearcher;
 import org.junit.jupiter.api.Test;
 
+import java.util.Optional;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 class StorageNodeNodePathTest {
     
@@ -30,4 +34,10 @@ class StorageNodeNodePathTest {
         assertThat(NodePathGenerator.toPath(new StorageNodeNodePath("foo_db", 
null), false), is("/metadata/foo_db/data_sources/nodes"));
         assertThat(NodePathGenerator.toPath(new StorageNodeNodePath("foo_db", 
"foo_storage_node"), false), 
is("/metadata/foo_db/data_sources/nodes/foo_storage_node"));
     }
+    
+    @Test
+    void assertCreateStorageNodeSearchCriteria() {
+        
assertThat(NodePathSearcher.find("/metadata/foo_db/data_sources/nodes/foo_ds", 
StorageNodeNodePath.createStorageNodeSearchCriteria()), 
is(Optional.of("foo_ds")));
+        
assertFalse(NodePathSearcher.find("/xxx/foo_db/data_sources/nodes/foo_ds", 
StorageNodeNodePath.createStorageNodeSearchCriteria()).isPresent());
+    }
 }
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParserTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParserTest.java
deleted file mode 100644
index 2f682e9b79c..00000000000
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathParserTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.path.metadata.storage;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class StorageUnitNodePathParserTest {
-    
-    @Test
-    void assertFindStorageUnitName() {
-        Optional<String> actual = 
StorageUnitNodePathParser.findStorageUnitName("/metadata/foo_db/data_sources/units/foo_ds");
-        assertTrue(actual.isPresent());
-        assertThat(actual.get(), is("foo_ds"));
-    }
-    
-    @Test
-    void assertFindStorageUnitNameIfNotFound() {
-        
assertFalse(StorageUnitNodePathParser.findStorageUnitName("/xxx/foo_db/data_sources/units/foo_ds").isPresent());
-    }
-}
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathTest.java
index aebda7a78de..5f6082f0291 100644
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathTest.java
+++ 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/StorageUnitNodePathTest.java
@@ -18,10 +18,15 @@
 package org.apache.shardingsphere.mode.node.path.metadata.storage;
 
 import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NodePathSearcher;
 import org.junit.jupiter.api.Test;
 
+import java.util.Optional;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class StorageUnitNodePathTest {
     
@@ -30,4 +35,19 @@ class StorageUnitNodePathTest {
         assertThat(NodePathGenerator.toPath(new StorageUnitNodePath("foo_db", 
null), false), is("/metadata/foo_db/data_sources/units"));
         assertThat(NodePathGenerator.toPath(new StorageUnitNodePath("foo_db", 
"foo_storage_unit"), false), 
is("/metadata/foo_db/data_sources/units/foo_storage_unit"));
     }
+    
+    @Test
+    void assertCreateDataSourceSearchCriteria() {
+        
assertThat(NodePathSearcher.find("/metadata/foo_db/data_sources/units/foo_ds", 
StorageUnitNodePath.createDataSourceSearchCriteria()), 
is(Optional.of("foo_db")));
+        
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/data_sources/units/foo_ds",
 StorageUnitNodePath.createDataSourceSearchCriteria()));
+        
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/data_sources/foo_ds",
 StorageUnitNodePath.createDataSourceSearchCriteria()));
+        
assertTrue(NodePathSearcher.isMatchedPath("/metadata/foo_db/data_sources", 
StorageUnitNodePath.createDataSourceSearchCriteria()));
+        assertFalse(NodePathSearcher.isMatchedPath("/metadata/foo_db", 
StorageUnitNodePath.createDataSourceSearchCriteria()));
+    }
+    
+    @Test
+    void assertCreateStorageUnitSearchCriteria() {
+        
assertThat(NodePathSearcher.find("/metadata/foo_db/data_sources/units/foo_ds", 
StorageUnitNodePath.createStorageUnitSearchCriteria()), 
is(Optional.of("foo_ds")));
+        
assertFalse(NodePathSearcher.find("/xxx/foo_db/data_sources/units/foo_ds", 
StorageUnitNodePath.createStorageUnitSearchCriteria()).isPresent());
+    }
 }
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/metadata/MetaDataChangedHandler.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/metadata/MetaDataChangedHandler.java
index 1c5a1bfc345..1722d1a7588 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/metadata/MetaDataChangedHandler.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/metadata/MetaDataChangedHandler.java
@@ -28,9 +28,8 @@ import 
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.database.
 import org.apache.shardingsphere.mode.node.path.NodePathSearcher;
 import 
org.apache.shardingsphere.mode.node.path.metadata.database.TableMetadataNodePath;
 import 
org.apache.shardingsphere.mode.node.path.metadata.database.ViewMetadataNodePath;
-import 
org.apache.shardingsphere.mode.node.path.metadata.storage.DataSourceNodePathParser;
-import 
org.apache.shardingsphere.mode.node.path.metadata.storage.StorageNodeNodePathParser;
-import 
org.apache.shardingsphere.mode.node.path.metadata.storage.StorageUnitNodePathParser;
+import 
org.apache.shardingsphere.mode.node.path.metadata.storage.StorageNodeNodePath;
+import 
org.apache.shardingsphere.mode.node.path.metadata.storage.StorageUnitNodePath;
 
 import java.util.Optional;
 
@@ -80,7 +79,7 @@ public final class MetaDataChangedHandler {
             handleViewChanged(databaseName, schemaName.get(), event);
             return true;
         }
-        if (DataSourceNodePathParser.isDataSourcePath(eventKey)) {
+        if (NodePathSearcher.isMatchedPath(eventKey, 
StorageUnitNodePath.createDataSourceSearchCriteria())) {
             handleDataSourceChanged(databaseName, event);
             return true;
         }
@@ -121,20 +120,20 @@ public final class MetaDataChangedHandler {
     }
     
     private void handleDataSourceChanged(final String databaseName, final 
DataChangedEvent event) {
-        Optional<String> storageUnitName = 
StorageUnitNodePathParser.getVersion().findIdentifierByActiveVersionPath(event.getKey(),
 2);
+        Optional<String> storageUnitName = NodePathSearcher.getVersion(new 
StorageUnitNodePath()).findIdentifierByActiveVersionPath(event.getKey(), 2);
         boolean isActiveVersion = true;
         if (!storageUnitName.isPresent()) {
-            storageUnitName = 
StorageUnitNodePathParser.findStorageUnitName(event.getKey());
+            storageUnitName = NodePathSearcher.find(event.getKey(), 
StorageUnitNodePath.createStorageUnitSearchCriteria());
             isActiveVersion = false;
         }
         if (storageUnitName.isPresent()) {
             handleStorageUnitChanged(databaseName, event, 
storageUnitName.get(), isActiveVersion);
             return;
         }
-        Optional<String> storageNodeName = 
StorageNodeNodePathParser.getVersion().findIdentifierByActiveVersionPath(event.getKey(),
 2);
+        Optional<String> storageNodeName = NodePathSearcher.getVersion(new 
StorageNodeNodePath()).findIdentifierByActiveVersionPath(event.getKey(), 2);
         isActiveVersion = true;
         if (!storageNodeName.isPresent()) {
-            storageNodeName = 
StorageNodeNodePathParser.findStorageNodeName(event.getKey());
+            storageNodeName = NodePathSearcher.find(event.getKey(), 
StorageNodeNodePath.createStorageNodeSearchCriteria());
             isActiveVersion = false;
         }
         if (storageNodeName.isPresent()) {

Reply via email to