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 46f28441893 Rename ShardingSphereStatisticsNodePath (#34431)
46f28441893 is described below
commit 46f28441893e40814ea34a1078e3b824b963431d
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Jan 22 23:42:15 2025 +0800
Rename ShardingSphereStatisticsNodePath (#34431)
* Rename ShardingSphereStatisticsNodePath
* Rename ShardingSphereStatisticsNodePath
---
.../collect/StatisticsCollectJobWorker.java | 4 +-
.../data/ShardingSphereDataPersistService.java | 12 +--
.../metadata/table/TableRowDataPersistService.java | 13 +--
....java => ShardingSphereStatisticsNodePath.java} | 4 +-
.../node/path/ShardingSphereDataNodePathTest.java | 114 ---------------------
.../path/ShardingSphereStatisticsNodePathTest.java | 114 +++++++++++++++++++++
...=> ShardingSphereStatisticsChangedHandler.java} | 22 ++--
...luster.dispatch.handler.DataChangedEventHandler | 2 +-
...hardingSphereStatisticsChangedHandlerTest.java} | 2 +-
9 files changed, 144 insertions(+), 143 deletions(-)
diff --git
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
index d35d04b7fd9..9da01a46f8e 100644
---
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
+++
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
import
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereDataNodePath;
+import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereStatisticsNodePath;
import org.apache.shardingsphere.mode.manager.ContextManager;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
@@ -68,7 +68,7 @@ public final class StatisticsCollectJobWorker {
private CoordinatorRegistryCenter createRegistryCenter(final
ModeConfiguration modeConfig) {
ClusterPersistRepositoryConfiguration repositoryConfig =
(ClusterPersistRepositoryConfiguration) modeConfig.getRepository();
- String namespace = repositoryConfig.getNamespace() +
ShardingSphereDataNodePath.getJobPath();
+ String namespace = repositoryConfig.getNamespace() +
ShardingSphereStatisticsNodePath.getJobPath();
CoordinatorRegistryCenter result = new
ZookeeperRegistryCenter(getZookeeperConfiguration(repositoryConfig, namespace));
result.init();
return result;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/data/ShardingSphereDataPersistService.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/data/ShardingSphereDataPersistService.java
index 0e76eb367e1..41eafda35a0 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/data/ShardingSphereDataPersistService.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/data/ShardingSphereDataPersistService.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatist
import
org.apache.shardingsphere.infra.yaml.data.pojo.YamlShardingSphereRowData;
import
org.apache.shardingsphere.infra.yaml.data.swapper.YamlShardingSphereRowDataSwapper;
import
org.apache.shardingsphere.mode.metadata.persist.service.metadata.table.TableRowDataPersistService;
-import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereDataNodePath;
+import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereStatisticsNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import java.util.ArrayList;
@@ -54,7 +54,7 @@ public final class ShardingSphereDataPersistService {
* @return statistics
*/
public ShardingSphereStatistics load(final ShardingSphereMetaData
metaData) {
- Collection<String> databaseNames =
repository.getChildrenKeys(ShardingSphereDataNodePath.getDatabasesRootPath());
+ Collection<String> databaseNames =
repository.getChildrenKeys(ShardingSphereStatisticsNodePath.getDatabasesRootPath());
if (databaseNames.isEmpty()) {
return new ShardingSphereStatistics();
}
@@ -67,7 +67,7 @@ public final class ShardingSphereDataPersistService {
private ShardingSphereDatabaseData load(final ShardingSphereDatabase
database) {
ShardingSphereDatabaseData result = new ShardingSphereDatabaseData();
- for (String each :
repository.getChildrenKeys(ShardingSphereDataNodePath.getSchemaRootPath(database.getName())).stream().filter(database::containsSchema).collect(Collectors.toList()))
{
+ for (String each :
repository.getChildrenKeys(ShardingSphereStatisticsNodePath.getSchemaRootPath(database.getName())).stream().filter(database::containsSchema).collect(Collectors.toList()))
{
result.putSchema(each, load(database.getName(),
database.getSchema(each)));
}
return result;
@@ -75,7 +75,7 @@ public final class ShardingSphereDataPersistService {
private ShardingSphereSchemaData load(final String databaseName, final
ShardingSphereSchema schema) {
ShardingSphereSchemaData result = new ShardingSphereSchemaData();
- for (String each :
repository.getChildrenKeys(ShardingSphereDataNodePath.getTableRootPath(databaseName,
schema.getName())).stream().filter(schema::containsTable)
+ for (String each :
repository.getChildrenKeys(ShardingSphereStatisticsNodePath.getTableRootPath(databaseName,
schema.getName())).stream().filter(schema::containsTable)
.collect(Collectors.toList())) {
result.getTableData().put(each,
tableRowDataPersistService.load(databaseName, schema.getName(),
schema.getTable(each)));
@@ -98,7 +98,7 @@ public final class ShardingSphereDataPersistService {
}
private void persistSchema(final String databaseName, final String
schemaName) {
-
repository.persist(ShardingSphereDataNodePath.getSchemaPath(databaseName,
schemaName), "");
+
repository.persist(ShardingSphereStatisticsNodePath.getSchemaPath(databaseName,
schemaName), "");
}
private void persistTableData(final ShardingSphereDatabase database, final
String schemaName, final ShardingSphereSchemaData schemaData) {
@@ -130,6 +130,6 @@ public final class ShardingSphereDataPersistService {
* @param databaseName database name
*/
public void delete(final String databaseName) {
-
repository.delete(ShardingSphereDataNodePath.getDatabasePath(databaseName));
+
repository.delete(ShardingSphereStatisticsNodePath.getDatabasePath(databaseName));
}
}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/metadata/table/TableRowDataPersistService.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/metadata/table/TableRowDataPersistService.java
index c0414687710..b4460d373de 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/metadata/table/TableRowDataPersistService.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/metadata/table/TableRowDataPersistService.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.data.pojo.YamlShardingSphereRowData;
import
org.apache.shardingsphere.infra.yaml.data.swapper.YamlShardingSphereRowDataSwapper;
-import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereDataNodePath;
+import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereStatisticsNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import java.util.ArrayList;
@@ -48,9 +48,10 @@ public final class TableRowDataPersistService {
*/
public void persist(final String databaseName, final String schemaName,
final String tableName, final Collection<YamlShardingSphereRowData> rows) {
if (rows.isEmpty()) {
-
repository.persist(ShardingSphereDataNodePath.getTablePath(databaseName,
schemaName, tableName.toLowerCase()), "");
+
repository.persist(ShardingSphereStatisticsNodePath.getTablePath(databaseName,
schemaName, tableName.toLowerCase()), "");
} else {
- rows.forEach(each ->
repository.persist(ShardingSphereDataNodePath.getTableRowPath(databaseName,
schemaName, tableName.toLowerCase(), each.getUniqueKey()),
YamlEngine.marshal(each)));
+ rows.forEach(
+ each ->
repository.persist(ShardingSphereStatisticsNodePath.getTableRowPath(databaseName,
schemaName, tableName.toLowerCase(), each.getUniqueKey()),
YamlEngine.marshal(each)));
}
}
@@ -63,7 +64,7 @@ public final class TableRowDataPersistService {
* @param rows rows
*/
public void delete(final String databaseName, final String schemaName,
final String tableName, final Collection<YamlShardingSphereRowData> rows) {
- rows.forEach(each ->
repository.delete(ShardingSphereDataNodePath.getTableRowPath(databaseName,
schemaName, tableName.toLowerCase(), each.getUniqueKey())));
+ rows.forEach(each ->
repository.delete(ShardingSphereStatisticsNodePath.getTableRowPath(databaseName,
schemaName, tableName.toLowerCase(), each.getUniqueKey())));
}
/**
@@ -77,8 +78,8 @@ public final class TableRowDataPersistService {
public ShardingSphereTableData load(final String databaseName, final
String schemaName, final ShardingSphereTable table) {
ShardingSphereTableData result = new
ShardingSphereTableData(table.getName());
YamlShardingSphereRowDataSwapper swapper = new
YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getAllColumns()));
- for (String each :
repository.getChildrenKeys(ShardingSphereDataNodePath.getTablePath(databaseName,
schemaName, table.getName()))) {
- String yamlRow =
repository.query(ShardingSphereDataNodePath.getTableRowPath(databaseName,
schemaName, table.getName(), each));
+ for (String each :
repository.getChildrenKeys(ShardingSphereStatisticsNodePath.getTablePath(databaseName,
schemaName, table.getName()))) {
+ String yamlRow =
repository.query(ShardingSphereStatisticsNodePath.getTableRowPath(databaseName,
schemaName, table.getName(), each));
if (!Strings.isNullOrEmpty(yamlRow)) {
result.getRows().add(swapper.swapToObject(YamlEngine.unmarshal(yamlRow,
YamlShardingSphereRowData.class)));
}
diff --git
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereDataNodePath.java
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereStatisticsNodePath.java
similarity index 98%
rename from
mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereDataNodePath.java
rename to
mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereStatisticsNodePath.java
index ef45964e201..66d8231270b 100644
---
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereDataNodePath.java
+++
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/ShardingSphereStatisticsNodePath.java
@@ -25,10 +25,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * ShardingSphere data node path.
+ * ShardingSphere statistics node path.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingSphereDataNodePath {
+public final class ShardingSphereStatisticsNodePath {
private static final String ROOT_NODE = "/statistics";
diff --git
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereDataNodePathTest.java
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereDataNodePathTest.java
deleted file mode 100644
index 1bc4a79f1aa..00000000000
---
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereDataNodePathTest.java
+++ /dev/null
@@ -1,114 +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;
-
-import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereDataNodePath;
-import org.junit.jupiter.api.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ShardingSphereDataNodePathTest {
-
- @Test
- void assertGetDatabasesRootPath() {
- assertThat(ShardingSphereDataNodePath.getDatabasesRootPath(),
is("/statistics/databases"));
- }
-
- @Test
- void assertGetDatabasePath() {
- assertThat(ShardingSphereDataNodePath.getDatabasePath("foo_db"),
is("/statistics/databases/foo_db"));
- }
-
- @Test
- void assertGetSchemaRootPath() {
- assertThat(ShardingSphereDataNodePath.getSchemaRootPath("foo_db"),
is("/statistics/databases/foo_db/schemas"));
- }
-
- @Test
- void assertGetSchemaPath() {
- assertThat(ShardingSphereDataNodePath.getSchemaPath("foo_db",
"db_schema"), is("/statistics/databases/foo_db/schemas/db_schema"));
- }
-
- @Test
- void assertGetTableRootPath() {
- assertThat(ShardingSphereDataNodePath.getTableRootPath("foo_db",
"db_schema"), is("/statistics/databases/foo_db/schemas/db_schema/tables"));
- }
-
- @Test
- void assertGetTablePath() {
- assertThat(ShardingSphereDataNodePath.getTablePath("foo_db",
"db_schema", "tbl_name"),
is("/statistics/databases/foo_db/schemas/db_schema/tables/tbl_name"));
- }
-
- @Test
- void assertGetTableRowPath() {
- assertThat(ShardingSphereDataNodePath.getTableRowPath("foo_db",
"db_schema", "tbl_name", "key"),
is("/statistics/databases/foo_db/schemas/db_schema/tables/tbl_name/key"));
- }
-
- @Test
- void assertFindDatabaseNameWithNotContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findDatabaseName("/statistics/databases/foo_db",
false), is(Optional.of("foo_db")));
-
assertThat(ShardingSphereDataNodePath.findDatabaseName("/statistics/databases",
false), is(Optional.empty()));
- }
-
- @Test
- void assertFindDatabaseNameWithContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findDatabaseName("/statistics/databases/foo_db",
true), is(Optional.of("foo_db")));
-
assertThat(ShardingSphereDataNodePath.findDatabaseName("/statistics/databases/foo_db/schemas/db_schema",
true), is(Optional.of("foo_db")));
-
assertThat(ShardingSphereDataNodePath.findDatabaseName("/statistics/databases",
true), is(Optional.empty()));
- }
-
- @Test
- void assertFindSchemaNameWithNotContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema",
false), is(Optional.of("foo_schema")));
-
assertThat(ShardingSphereDataNodePath.findSchemaName("/statistics/databases/foo_db",
false), is(Optional.empty()));
- }
-
- @Test
- void assertFindSchemaNameWithContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema",
true), is(Optional.of("foo_schema")));
-
assertThat(ShardingSphereDataNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema/tables/foo_tbl",
true), is(Optional.of("foo_schema")));
-
assertThat(ShardingSphereDataNodePath.findSchemaName("/statistics/databases/foo_db",
true), is(Optional.empty()));
- }
-
- @Test
- void assertFindTableNameWithNotContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name",
false), is(Optional.of("tbl_name")));
-
assertThat(ShardingSphereDataNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema",
false), is(Optional.empty()));
- }
-
- @Test
- void assertFindTableNameWithContainsChildPath() {
-
assertThat(ShardingSphereDataNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name",
true), is(Optional.of("tbl_name")));
-
assertThat(ShardingSphereDataNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name/key",
true), is(Optional.of("tbl_name")));
-
assertThat(ShardingSphereDataNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables",
true), is(Optional.empty()));
- }
-
- @Test
- void assertFindRowUniqueKey() {
-
assertThat(ShardingSphereDataNodePath.findRowUniqueKey("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name/key"),
is(Optional.of("key")));
-
assertThat(ShardingSphereDataNodePath.findRowUniqueKey("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name"),
is(Optional.empty()));
- }
-
- @Test
- void assertGetJobPath() {
- assertThat(ShardingSphereDataNodePath.getJobPath(),
is("/statistics/job"));
- }
-}
diff --git
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereStatisticsNodePathTest.java
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereStatisticsNodePathTest.java
new file mode 100644
index 00000000000..3bb6fa566d8
--- /dev/null
+++
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/ShardingSphereStatisticsNodePathTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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;
+
+import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereStatisticsNodePath;
+import org.junit.jupiter.api.Test;
+
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class ShardingSphereStatisticsNodePathTest {
+
+ @Test
+ void assertGetDatabasesRootPath() {
+ assertThat(ShardingSphereStatisticsNodePath.getDatabasesRootPath(),
is("/statistics/databases"));
+ }
+
+ @Test
+ void assertGetDatabasePath() {
+ assertThat(ShardingSphereStatisticsNodePath.getDatabasePath("foo_db"),
is("/statistics/databases/foo_db"));
+ }
+
+ @Test
+ void assertGetSchemaRootPath() {
+
assertThat(ShardingSphereStatisticsNodePath.getSchemaRootPath("foo_db"),
is("/statistics/databases/foo_db/schemas"));
+ }
+
+ @Test
+ void assertGetSchemaPath() {
+ assertThat(ShardingSphereStatisticsNodePath.getSchemaPath("foo_db",
"db_schema"), is("/statistics/databases/foo_db/schemas/db_schema"));
+ }
+
+ @Test
+ void assertGetTableRootPath() {
+ assertThat(ShardingSphereStatisticsNodePath.getTableRootPath("foo_db",
"db_schema"), is("/statistics/databases/foo_db/schemas/db_schema/tables"));
+ }
+
+ @Test
+ void assertGetTablePath() {
+ assertThat(ShardingSphereStatisticsNodePath.getTablePath("foo_db",
"db_schema", "tbl_name"),
is("/statistics/databases/foo_db/schemas/db_schema/tables/tbl_name"));
+ }
+
+ @Test
+ void assertGetTableRowPath() {
+ assertThat(ShardingSphereStatisticsNodePath.getTableRowPath("foo_db",
"db_schema", "tbl_name", "key"),
is("/statistics/databases/foo_db/schemas/db_schema/tables/tbl_name/key"));
+ }
+
+ @Test
+ void assertFindDatabaseNameWithNotContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findDatabaseName("/statistics/databases/foo_db",
false), is(Optional.of("foo_db")));
+
assertThat(ShardingSphereStatisticsNodePath.findDatabaseName("/statistics/databases",
false), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindDatabaseNameWithContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findDatabaseName("/statistics/databases/foo_db",
true), is(Optional.of("foo_db")));
+
assertThat(ShardingSphereStatisticsNodePath.findDatabaseName("/statistics/databases/foo_db/schemas/db_schema",
true), is(Optional.of("foo_db")));
+
assertThat(ShardingSphereStatisticsNodePath.findDatabaseName("/statistics/databases",
true), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindSchemaNameWithNotContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema",
false), is(Optional.of("foo_schema")));
+
assertThat(ShardingSphereStatisticsNodePath.findSchemaName("/statistics/databases/foo_db",
false), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindSchemaNameWithContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema",
true), is(Optional.of("foo_schema")));
+
assertThat(ShardingSphereStatisticsNodePath.findSchemaName("/statistics/databases/foo_db/schemas/foo_schema/tables/foo_tbl",
true), is(Optional.of("foo_schema")));
+
assertThat(ShardingSphereStatisticsNodePath.findSchemaName("/statistics/databases/foo_db",
true), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindTableNameWithNotContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name",
false), is(Optional.of("tbl_name")));
+
assertThat(ShardingSphereStatisticsNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema",
false), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindTableNameWithContainsChildPath() {
+
assertThat(ShardingSphereStatisticsNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name",
true), is(Optional.of("tbl_name")));
+
assertThat(ShardingSphereStatisticsNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name/key",
true), is(Optional.of("tbl_name")));
+
assertThat(ShardingSphereStatisticsNodePath.findTableName("/statistics/databases/foo_db/schemas/foo_schema/tables",
true), is(Optional.empty()));
+ }
+
+ @Test
+ void assertFindRowUniqueKey() {
+
assertThat(ShardingSphereStatisticsNodePath.findRowUniqueKey("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name/key"),
is(Optional.of("key")));
+
assertThat(ShardingSphereStatisticsNodePath.findRowUniqueKey("/statistics/databases/foo_db/schemas/foo_schema/tables/tbl_name"),
is(Optional.empty()));
+ }
+
+ @Test
+ void assertGetJobPath() {
+ assertThat(ShardingSphereStatisticsNodePath.getJobPath(),
is("/statistics/job"));
+ }
+}
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandler.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandler.java
similarity index 85%
rename from
mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandler.java
rename to
mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandler.java
index d8000025419..ca5fc2c6fa4 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandler.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandler.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.data.pojo.YamlShardingSphereRowData;
-import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereDataNodePath;
+import
org.apache.shardingsphere.mode.node.path.metadata.ShardingSphereStatisticsNodePath;
import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -32,13 +32,13 @@ import java.util.Collection;
import java.util.Optional;
/**
- * ShardingSphere data changed handler.
+ * ShardingSphere statistics changed handler.
*/
-public final class ShardingSphereDataChangedHandler implements
DataChangedEventHandler {
+public final class ShardingSphereStatisticsChangedHandler implements
DataChangedEventHandler {
@Override
public String getSubscribedKey() {
- return ShardingSphereDataNodePath.getDatabasesRootPath();
+ return ShardingSphereStatisticsNodePath.getDatabasesRootPath();
}
@Override
@@ -49,34 +49,34 @@ public final class ShardingSphereDataChangedHandler
implements DataChangedEventH
@Override
public void handle(final ContextManager contextManager, final
DataChangedEvent event) {
ShardingSphereDatabaseDataManager databaseManager =
contextManager.getMetaDataContextManager().getDatabaseManager();
- Optional<String> databaseName =
ShardingSphereDataNodePath.findDatabaseName(event.getKey(), false);
+ Optional<String> databaseName =
ShardingSphereStatisticsNodePath.findDatabaseName(event.getKey(), false);
if (databaseName.isPresent()) {
handleDatabaseChanged(databaseManager, event.getType(),
databaseName.get());
return;
}
- databaseName =
ShardingSphereDataNodePath.findDatabaseName(event.getKey(), true);
+ databaseName =
ShardingSphereStatisticsNodePath.findDatabaseName(event.getKey(), true);
if (!databaseName.isPresent()) {
return;
}
- Optional<String> schemaName =
ShardingSphereDataNodePath.findSchemaName(event.getKey(), false);
+ Optional<String> schemaName =
ShardingSphereStatisticsNodePath.findSchemaName(event.getKey(), false);
if (schemaName.isPresent()) {
handleSchemaChanged(databaseManager, event.getType(),
databaseName.get(), schemaName.get());
return;
}
- schemaName = ShardingSphereDataNodePath.findSchemaName(event.getKey(),
true);
+ schemaName =
ShardingSphereStatisticsNodePath.findSchemaName(event.getKey(), true);
if (!schemaName.isPresent()) {
return;
}
- Optional<String> tableName =
ShardingSphereDataNodePath.findTableName(event.getKey(), false);
+ Optional<String> tableName =
ShardingSphereStatisticsNodePath.findTableName(event.getKey(), false);
if (tableName.isPresent()) {
handleTableChanged(databaseManager, event.getType(),
databaseName.get(), schemaName.get(), tableName.get());
return;
}
- tableName = ShardingSphereDataNodePath.findTableName(event.getKey(),
true);
+ tableName =
ShardingSphereStatisticsNodePath.findTableName(event.getKey(), true);
if (!tableName.isPresent()) {
return;
}
- Optional<String> uniqueKey =
ShardingSphereDataNodePath.findRowUniqueKey(event.getKey());
+ Optional<String> uniqueKey =
ShardingSphereStatisticsNodePath.findRowUniqueKey(event.getKey());
if (uniqueKey.isPresent()) {
handleRowDataChanged(databaseManager, event.getType(),
event.getValue(), databaseName.get(), schemaName.get(), tableName.get(),
uniqueKey.get());
}
diff --git
a/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.DataChangedEventHandler
b/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.DataChangedEventHandler
index 8018c00ee1d..df5c55d6443 100644
---
a/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.DataChangedEventHandler
+++
b/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.DataChangedEventHandler
@@ -19,7 +19,7 @@
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ClusterSt
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.QualifiedDataSourceChangedHandler
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ComputeNodeOnlineHandler
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ComputeNodeStateChangedHandler
-org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ShardingSphereDataChangedHandler
+org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ShardingSphereStatisticsChangedHandler
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalRuleChangedHandler
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.PropertiesChangedHandler
org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.ListenerAssistedChangedHandler
diff --git
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandlerTest.java
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandlerTest.java
similarity index 99%
rename from
mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandlerTest.java
rename to
mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandlerTest.java
index 4484a76fccb..8f492b6eba4 100644
---
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereDataChangedHandlerTest.java
+++
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/ShardingSphereStatisticsChangedHandlerTest.java
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
-class ShardingSphereDataChangedHandlerTest {
+class ShardingSphereStatisticsChangedHandlerTest {
private DataChangedEventHandler handler;