You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/02/21 13:43:13 UTC
(shardingsphere) branch master updated: Add NewNodePathGenerator and NodePathEntity to process node path (#34735)
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 c2b2a7eeea2 Add NewNodePathGenerator and NodePathEntity to process node path (#34735)
c2b2a7eeea2 is described below
commit c2b2a7eeea23bf339afedac55a33547e815ee906
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Feb 21 21:43:07 2025 +0800
Add NewNodePathGenerator and NodePathEntity to process node path (#34735)
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
* Add NewNodePathGenerator and NodePathEntity to process node path
---
...ittingQualifiedDataSourceChangedSubscriber.java | 4 +-
.../collect/StatisticsCollectJobWorker.java | 5 +-
.../database/DataSourceUnitPersistService.java | 10 +--
.../database/DatabaseRulePersistService.java | 16 ++---
.../config/global/GlobalRulePersistService.java | 10 ++-
.../config/global/PropertiesPersistService.java | 8 +--
.../service/SchemaMetaDataPersistService.java | 11 ++-
.../service/TableMetaDataPersistService.java | 14 ++--
.../service/TableRowDataPersistService.java | 15 ++--
.../service/ViewMetaDataPersistService.java | 14 ++--
.../statistics/StatisticsPersistService.java | 19 +++--
.../state/cluster/ClusterStatePersistService.java | 7 +-
.../mode/state/node/ComputeNodePersistService.java | 35 +++++-----
.../QualifiedDataSourceStatePersistService.java | 8 +--
.../mode/manager/ContextManagerTest.java | 4 +-
.../StatesNodePath.java => NewNodePath.java} | 15 +---
.../mode/node/path/NewNodePathGenerator.java | 80 ++++++++++++++++++++++
...GlobalRuleNodePath.java => NodePathEntity.java} | 25 ++++---
.../config/global/GlobalPropertiesNodePath.java | 17 +++--
.../global/GlobalPropertiesNodePathParser.java | 3 +-
.../path/config/global/GlobalRuleNodePath.java | 19 ++---
.../config/global/GlobalRuleNodePathParser.java | 3 +-
...ExecutionNodePath.java => ProcessNodePath.java} | 17 +++--
.../path/metadata/database/SchemaNodePath.java | 46 -------------
.../metadata/database/SchemaNodePathParser.java | 5 +-
.../metadata/database/TableMetadataNodePath.java} | 25 ++++---
.../node/path/metadata/database/TableNodePath.java | 48 -------------
.../metadata/database/TableNodePathParser.java | 8 ++-
.../metadata/database/ViewMetadataNodePath.java} | 25 ++++---
.../node/path/metadata/database/ViewNodePath.java | 48 -------------
.../path/metadata/database/ViewNodePathParser.java | 8 ++-
.../metadata/rule/DatabaseRuleItemNodePath.java | 41 -----------
.../path/metadata/rule/DatabaseRuleNodePath.java | 20 +++---
.../path/metadata/storage/DataSourceNodePath.java | 46 -------------
.../metadata/storage/DataSourceNodePathParser.java | 4 +-
.../path/metadata/storage/StorageNodeNodePath.java | 29 +++-----
.../storage/StorageNodeNodePathParser.java | 8 ++-
.../path/metadata/storage/StorageUnitNodePath.java | 27 +++-----
.../storage/StorageUnitNodePathParser.java | 8 ++-
.../path/node/compute/label/LabelNodePath.java | 21 +++---
.../process/KillProcessTriggerNodePath.java | 21 +++---
.../process/ShowProcessListTriggerNodePath.java | 21 +++---
...neInstanceNodePath.java => OnlineNodePath.java} | 23 ++++---
.../node/compute/status/OnlineTypeNodePath.java | 37 ----------
.../path/node/compute/status/StatusNodePath.java | 21 +++---
.../workerid/ComputeNodeWorkerIDNodePath.java | 21 +++---
.../node/storage/QualifiedDataSourceNodePath.java | 22 +++---
.../storage/QualifiedDataSourceNodePathParser.java | 4 +-
...ePath.java => WorkerIDReservationNodePath.java} | 19 ++---
.../workerid/WorkerIDReservationNodePath.java | 37 ----------
.../{StatesNodePath.java => ClusterNodePath.java} | 15 ++--
.../DatabaseListenerCoordinatorNodePath.java | 23 +++----
.../DatabaseListenerCoordinatorNodePathParser.java | 6 +-
.../node/path/state/cluster/ClusterNodePath.java | 37 ----------
.../StatisticsDataNodePath.java} | 25 +++----
.../StatisticsJobNodePath.java} | 17 ++---
.../path/statistics/StatisticsNodePathParser.java | 18 ++---
.../database/StatisticsDatabaseNodePath.java | 37 ----------
.../database/StatisticsSchemaNodePath.java | 45 ------------
.../database/StatisticsTableNodePath.java | 48 -------------
.../database/StatisticsTableRowNodePath.java | 46 -------------
.../path/statistics/job/StatisticsJobNodePath.java | 37 ----------
.../global/GlobalPropertiesNodePathTest.java | 5 +-
.../path/config/global/GlobalRuleNodePathTest.java | 6 +-
...nNodePathTest.java => ProcessNodePathTest.java} | 8 ++-
.../execution/process/ProcessNodePathTest.java | 31 ---------
.../database/TableMetadataNodePathTest.java | 44 ++++++++++++
.../path/metadata/database/TableNodePathTest.java | 31 ---------
.../database/ViewMetadataNodePathTest.java | 44 ++++++++++++
.../rule/DatabaseRuleItemNodePathTest.java | 31 ---------
.../metadata/rule/DatabaseRuleNodePathTest.java | 20 +++++-
.../metadata/storage/DataSourceNodePathTest.java | 31 ---------
.../metadata/storage/StorageNodeNodePathTest.java | 6 +-
.../metadata/storage/StorageUnitNodePathTest.java | 6 +-
.../path/node/compute/label/LabelNodePathTest.java | 5 +-
.../process/KillProcessTriggerNodePathTest.java | 7 +-
.../ShowProcessListTriggerNodePathTest.java | 7 +-
...ceNodePathTest.java => OnlineNodePathTest.java} | 10 +--
.../compute/status/OnlineTypeNodePathTest.java | 31 ---------
.../node/compute/status/StatusNodePathTest.java | 6 +-
.../workerid/ComputeNodeWorkerIDNodePathTest.java | 5 +-
.../storage/QualifiedDataSourceNodePathTest.java | 9 ++-
...t.java => WorkerIDReservationNodePathTest.java} | 8 ++-
.../workerid/WorkerIDReservationNodePathTest.java | 31 ---------
...sNodePathTest.java => ClusterNodePathTest.java} | 7 +-
...abaseListenerCoordinatorNodePathParserTest.java | 2 +-
.../DatabaseListenerCoordinatorNodePathTest.java | 8 ++-
.../path/state/cluster/ClusterNodePathTest.java | 31 ---------
.../statistics/StatisticsDataNodePathTest.java | 40 +++++++++++
.../{job => }/StatisticsJobNodePathTest.java | 7 +-
.../database/StatisticsDatabaseNodePathTest.java | 31 ---------
.../database/StatisticsSchemaNodePathTest.java | 31 ---------
.../database/StatisticsTableNodePathTest.java | 31 ---------
.../database/StatisticsTableRowNodePathTest.java | 31 ---------
.../cluster/ClusterContextManagerBuilder.java | 12 ++--
.../global/type/ClusterStateChangedHandler.java | 5 +-
.../global/type/ComputeNodeOnlineHandler.java | 7 +-
.../type/ComputeNodeStateChangedHandler.java | 8 +--
.../type/DatabaseListenerChangedHandler.java | 7 +-
.../global/type/GlobalRuleChangedHandler.java | 3 +-
.../handler/global/type/KillProcessHandler.java | 5 +-
.../global/type/PropertiesChangedHandler.java | 3 +-
.../type/QualifiedDataSourceChangedHandler.java | 3 +-
.../global/type/ShowProcessListHandler.java | 5 +-
.../global/type/StatisticsChangedHandler.java | 5 +-
.../ClusterDatabaseListenerPersistCoordinator.java | 8 +--
.../process/ClusterProcessPersistCoordinator.java | 10 +--
.../service/ClusterProcessPersistService.java | 20 +++---
.../workerid/ReservationPersistService.java | 6 +-
109 files changed, 703 insertions(+), 1361 deletions(-)
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/deliver/ReadwriteSplittingQualifiedDataSourceChangedSubscriber.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/deliver/ReadwriteSplittingQualifiedDataSourceChangedSubscriber.java
index 44a9420e26a..16e1006f766 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/deliver/ReadwriteSplittingQualifiedDataSourceChangedSubscriber.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/deliver/ReadwriteSplittingQualifiedDataSourceChangedSubscriber.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.readwritesplitting.deliver;
import com.google.common.eventbus.Subscribe;
import lombok.Setter;
import org.apache.shardingsphere.mode.deliver.DeliverEventSubscriber;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.storage.QualifiedDataSourceNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -39,6 +39,6 @@ public final class ReadwriteSplittingQualifiedDataSourceChangedSubscriber implem
*/
@Subscribe
public void delete(final QualifiedDataSourceDeletedEvent event) {
- repository.delete(new NodePathGenerator(new QualifiedDataSourceNodePath()).getPath(event.getQualifiedDataSource()));
+ repository.delete(NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(event.getQualifiedDataSource()), false));
}
}
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 5eb96a64404..73595f747a9 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,8 @@ 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.statistics.job.StatisticsJobNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.statistics.StatisticsJobNodePath;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
@@ -68,7 +69,7 @@ public final class StatisticsCollectJobWorker {
private CoordinatorRegistryCenter createRegistryCenter(final ModeConfiguration modeConfig) {
ClusterPersistRepositoryConfiguration repositoryConfig = (ClusterPersistRepositoryConfiguration) modeConfig.getRepository();
- String namespace = repositoryConfig.getNamespace() + new StatisticsJobNodePath().getRootPath();
+ String namespace = repositoryConfig.getNamespace() + NewNodePathGenerator.generatePath(new StatisticsJobNodePath(), false);
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/config/database/DataSourceUnitPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DataSourceUnitPersistService.java
index baf05b83dcc..d239f17cd34 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DataSourceUnitPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DataSourceUnitPersistService.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePo
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.swapper.resource.YamlDataSourceConfigurationSwapper;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.metadata.storage.StorageUnitNodePath;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -56,7 +56,7 @@ public final class DataSourceUnitPersistService {
* @return data source pool properties map
*/
public Map<String, DataSourcePoolProperties> load(final String databaseName) {
- Collection<String> childrenKeys = repository.getChildrenKeys(new StorageUnitNodePath(databaseName).getRootPath());
+ Collection<String> childrenKeys = repository.getChildrenKeys(NewNodePathGenerator.generatePath(new StorageUnitNodePath(databaseName, null), false));
return childrenKeys.stream().collect(Collectors.toMap(each -> each, each -> load(databaseName, each), (a, b) -> b, () -> new LinkedHashMap<>(childrenKeys.size(), 1F)));
}
@@ -69,7 +69,7 @@ public final class DataSourceUnitPersistService {
*/
@SuppressWarnings("unchecked")
public DataSourcePoolProperties load(final String databaseName, final String dataSourceName) {
- VersionNodePath versionNodePath = new NodePathGenerator(new StorageUnitNodePath(databaseName)).getVersion(dataSourceName);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new StorageUnitNodePath(databaseName, dataSourceName));
int activeVersion = Integer.parseInt(repository.query(versionNodePath.getActiveVersionPath()));
String dataSourceContent = repository.query(versionNodePath.getVersionPath(activeVersion));
return yamlDataSourceConfigurationSwapper.swapToDataSourcePoolProperties(YamlEngine.unmarshal(dataSourceContent, Map.class));
@@ -83,7 +83,7 @@ public final class DataSourceUnitPersistService {
*/
public void persist(final String databaseName, final Map<String, DataSourcePoolProperties> dataSourcePropsMap) {
for (Entry<String, DataSourcePoolProperties> entry : dataSourcePropsMap.entrySet()) {
- VersionNodePath versionNodePath = new NodePathGenerator(new StorageUnitNodePath(databaseName)).getVersion(entry.getKey());
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new StorageUnitNodePath(databaseName, entry.getKey()));
metaDataVersionPersistService.persist(versionNodePath, YamlEngine.marshal(yamlDataSourceConfigurationSwapper.swapToMap(entry.getValue())));
}
}
@@ -95,6 +95,6 @@ public final class DataSourceUnitPersistService {
* @param dataSourceName data source name
*/
public void delete(final String databaseName, final String dataSourceName) {
- repository.delete(new NodePathGenerator(new StorageUnitNodePath(databaseName)).getPath(dataSourceName));
+ repository.delete(NewNodePathGenerator.generatePath(new StorageUnitNodePath(databaseName, dataSourceName), false));
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DatabaseRulePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DatabaseRulePersistService.java
index 6b0e4441bf1..787ed60909f 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DatabaseRulePersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/database/DatabaseRulePersistService.java
@@ -23,9 +23,8 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.metadata.persist.config.RepositoryTuplePersistService;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.config.database.item.DatabaseRuleItem;
-import org.apache.shardingsphere.mode.node.path.metadata.rule.DatabaseRuleItemNodePath;
import org.apache.shardingsphere.mode.node.path.metadata.rule.DatabaseRuleNodePath;
import org.apache.shardingsphere.mode.node.tuple.RepositoryTuple;
import org.apache.shardingsphere.mode.node.tuple.YamlRepositoryTupleSwapperEngine;
@@ -68,7 +67,8 @@ public final class DatabaseRulePersistService {
* @return configurations
*/
public Collection<RuleConfiguration> load(final String databaseName) {
- return yamlRepositoryTupleSwapperEngine.swapToRuleConfigurations(repositoryTuplePersistService.load(new DatabaseRuleNodePath(databaseName).getRootPath()));
+ return yamlRepositoryTupleSwapperEngine.swapToRuleConfigurations(
+ repositoryTuplePersistService.load(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath(databaseName, null, null), false)));
}
/**
@@ -91,11 +91,11 @@ public final class DatabaseRulePersistService {
private Collection<MetaDataVersion> persistDataNodes(final String databaseName, final String ruleType, final Collection<RepositoryTuple> repositoryTuples) {
Collection<MetaDataVersion> result = new LinkedList<>();
- NodePathGenerator nodePathGenerator = new NodePathGenerator(new DatabaseRuleItemNodePath(databaseName, ruleType));
for (RepositoryTuple each : repositoryTuples) {
DatabaseRuleItem databaseRuleItem = new DatabaseRuleItem(each.getKey());
- int nextVersion = metaDataVersionPersistService.persist(nodePathGenerator.getVersion(databaseRuleItem), each.getValue());
- result.add(new MetaDataVersion(nodePathGenerator.getPath(databaseRuleItem), Math.max(MetaDataVersion.INIT_VERSION, nextVersion - 1)));
+ DatabaseRuleNodePath databaseRuleNodePath = new DatabaseRuleNodePath(databaseName, ruleType, databaseRuleItem);
+ int nextVersion = metaDataVersionPersistService.persist(NewNodePathGenerator.generateVersionPath(databaseRuleNodePath), each.getValue());
+ result.add(new MetaDataVersion(NewNodePathGenerator.generatePath(databaseRuleNodePath, false), Math.max(MetaDataVersion.INIT_VERSION, nextVersion - 1)));
}
return result;
}
@@ -107,7 +107,7 @@ public final class DatabaseRulePersistService {
* @param ruleType rule type
*/
public void delete(final String databaseName, final String ruleType) {
- repository.delete(new NodePathGenerator(new DatabaseRuleNodePath(databaseName)).getPath(ruleType));
+ repository.delete(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath(databaseName, ruleType, null), false));
}
/**
@@ -133,7 +133,7 @@ public final class DatabaseRulePersistService {
private Collection<MetaDataVersion> delete(final String databaseName, final String ruleType, final Collection<RepositoryTuple> repositoryTuples) {
Collection<MetaDataVersion> result = new LinkedList<>();
for (RepositoryTuple each : repositoryTuples) {
- String toBeDeletedKey = new NodePathGenerator(new DatabaseRuleItemNodePath(databaseName, ruleType)).getPath(new DatabaseRuleItem(each.getKey()));
+ String toBeDeletedKey = NewNodePathGenerator.generatePath(new DatabaseRuleNodePath(databaseName, ruleType, new DatabaseRuleItem(each.getKey())), false);
repository.delete(toBeDeletedKey);
result.add(new MetaDataVersion(toBeDeletedKey));
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/GlobalRulePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/GlobalRulePersistService.java
index 777ab502542..6eca4e923f1 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/GlobalRulePersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/GlobalRulePersistService.java
@@ -22,9 +22,8 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.metadata.persist.config.RepositoryTuplePersistService;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalRuleNodePath;
-import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.apache.shardingsphere.mode.node.tuple.RepositoryTuple;
import org.apache.shardingsphere.mode.node.tuple.YamlRepositoryTupleSwapperEngine;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -58,7 +57,7 @@ public final class GlobalRulePersistService {
* @return global rule configurations
*/
public Collection<RuleConfiguration> load() {
- return yamlRepositoryTupleSwapperEngine.swapToRuleConfigurations(repositoryTuplePersistService.load(new GlobalRuleNodePath().getRootPath()));
+ return yamlRepositoryTupleSwapperEngine.swapToRuleConfigurations(repositoryTuplePersistService.load(NewNodePathGenerator.generatePath(new GlobalRuleNodePath(null), false)));
}
/**
@@ -68,7 +67,7 @@ public final class GlobalRulePersistService {
* @return global rule configuration
*/
public Optional<RuleConfiguration> load(final String ruleType) {
- return yamlRepositoryTupleSwapperEngine.swapToRuleConfiguration(ruleType, repositoryTuplePersistService.load(new NodePathGenerator(new GlobalRuleNodePath()).getPath(ruleType)));
+ return yamlRepositoryTupleSwapperEngine.swapToRuleConfiguration(ruleType, repositoryTuplePersistService.load(NewNodePathGenerator.generatePath(new GlobalRuleNodePath(ruleType), false)));
}
/**
@@ -84,8 +83,7 @@ public final class GlobalRulePersistService {
private void persistTuples(final Collection<RepositoryTuple> tuples) {
for (RepositoryTuple each : tuples) {
- VersionNodePath versionNodePath = new NodePathGenerator(new GlobalRuleNodePath()).getVersion(each.getKey());
- metaDataVersionPersistService.persist(versionNodePath, each.getValue());
+ metaDataVersionPersistService.persist(NewNodePathGenerator.generateVersionPath(new GlobalRuleNodePath(each.getKey())), each.getValue());
}
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/PropertiesPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/PropertiesPersistService.java
index c3f80382768..580aed165a7 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/PropertiesPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/config/global/PropertiesPersistService.java
@@ -21,7 +21,7 @@ import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalPropertiesNodePath;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -46,12 +46,12 @@ public final class PropertiesPersistService {
*/
public Properties load() {
return loadActiveVersion()
- .map(optional -> YamlEngine.unmarshal(repository.query(new NodePathGenerator(new GlobalPropertiesNodePath()).getVersion(null).getVersionPath(optional)), Properties.class))
+ .map(optional -> YamlEngine.unmarshal(repository.query(NewNodePathGenerator.generateVersionPath(new GlobalPropertiesNodePath()).getVersionPath(optional)), Properties.class))
.orElse(new Properties());
}
private Optional<Integer> loadActiveVersion() {
- String value = repository.query(new NodePathGenerator(new GlobalPropertiesNodePath()).getVersion(null).getActiveVersionPath());
+ String value = repository.query(NewNodePathGenerator.generateVersionPath(new GlobalPropertiesNodePath()).getActiveVersionPath());
return Strings.isNullOrEmpty(value) ? Optional.empty() : Optional.of(Integer.parseInt(value));
}
@@ -61,7 +61,7 @@ public final class PropertiesPersistService {
* @param props properties
*/
public void persist(final Properties props) {
- VersionNodePath versionNodePath = new NodePathGenerator(new GlobalPropertiesNodePath()).getVersion(null);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new GlobalPropertiesNodePath());
metaDataVersionPersistService.persist(versionNodePath, YamlEngine.marshal(props));
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/SchemaMetaDataPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/SchemaMetaDataPersistService.java
index dffc4fe3a8f..8fdc21b4d82 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/SchemaMetaDataPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/SchemaMetaDataPersistService.java
@@ -20,9 +20,8 @@ package org.apache.shardingsphere.mode.metadata.persist.metadata.service;
import org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.metadata.database.SchemaNodePath;
-import org.apache.shardingsphere.mode.node.path.metadata.database.TableNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.metadata.database.TableMetadataNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import java.util.Collection;
@@ -53,7 +52,7 @@ public final class SchemaMetaDataPersistService {
* @param schemaName to be added schema name
*/
public void add(final String databaseName, final String schemaName) {
- repository.persist(new TableNodePath(databaseName, schemaName).getRootPath(), "");
+ repository.persist(NewNodePathGenerator.generatePath(new TableMetadataNodePath(databaseName, schemaName, null), false), "");
}
/**
@@ -63,7 +62,7 @@ public final class SchemaMetaDataPersistService {
* @param schemaName to be dropped schema name
*/
public void drop(final String databaseName, final String schemaName) {
- repository.delete(new NodePathGenerator(new SchemaNodePath(databaseName)).getPath(schemaName));
+ repository.delete(NewNodePathGenerator.generatePath(new TableMetadataNodePath(databaseName, schemaName, null), true));
}
/**
@@ -113,7 +112,7 @@ public final class SchemaMetaDataPersistService {
* @return schemas
*/
public Collection<ShardingSphereSchema> load(final String databaseName) {
- return repository.getChildrenKeys(new SchemaNodePath(databaseName).getRootPath()).stream()
+ return repository.getChildrenKeys(NewNodePathGenerator.generatePath(new TableMetadataNodePath(databaseName, null, null), false)).stream()
.map(each -> new ShardingSphereSchema(each, tableMetaDataPersistService.load(databaseName, each), viewMetaDataPersistService.load(databaseName, each))).collect(Collectors.toList());
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableMetaDataPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableMetaDataPersistService.java
index 641be9af945..5104420563d 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableMetaDataPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableMetaDataPersistService.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereTable;
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlTableSwapper;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.metadata.database.TableNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.metadata.database.TableMetadataNodePath;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -51,8 +51,8 @@ public final class TableMetaDataPersistService {
* @return loaded tables
*/
public Collection<ShardingSphereTable> load(final String databaseName, final String schemaName) {
- return repository.getChildrenKeys(new TableNodePath(databaseName, schemaName).getRootPath()).stream().map(each -> load(databaseName, schemaName, each))
- .collect(Collectors.toList());
+ return repository.getChildrenKeys(NewNodePathGenerator.generatePath(new TableMetadataNodePath(databaseName, schemaName, null), false)).stream()
+ .map(each -> load(databaseName, schemaName, each)).collect(Collectors.toList());
}
/**
@@ -64,7 +64,7 @@ public final class TableMetaDataPersistService {
* @return loaded table
*/
public ShardingSphereTable load(final String databaseName, final String schemaName, final String tableName) {
- VersionNodePath versionNodePath = new NodePathGenerator(new TableNodePath(databaseName, schemaName)).getVersion(tableName);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new TableMetadataNodePath(databaseName, schemaName, tableName));
int activeVersion = Integer.parseInt(repository.query(versionNodePath.getActiveVersionPath()));
String tableContent = repository.query(versionNodePath.getVersionPath(activeVersion));
return swapper.swapToObject(YamlEngine.unmarshal(tableContent, YamlShardingSphereTable.class));
@@ -80,7 +80,7 @@ public final class TableMetaDataPersistService {
public void persist(final String databaseName, final String schemaName, final Collection<ShardingSphereTable> tables) {
for (ShardingSphereTable each : tables) {
String tableName = each.getName().toLowerCase();
- VersionNodePath versionNodePath = new NodePathGenerator(new TableNodePath(databaseName, schemaName)).getVersion(tableName);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new TableMetadataNodePath(databaseName, schemaName, tableName));
metaDataVersionPersistService.persist(versionNodePath, YamlEngine.marshal(swapper.swapToYamlConfiguration(each)));
}
}
@@ -93,7 +93,7 @@ public final class TableMetaDataPersistService {
* @param tableName to be dropped table name
*/
public void drop(final String databaseName, final String schemaName, final String tableName) {
- repository.delete(new NodePathGenerator(new TableNodePath(databaseName, schemaName)).getPath(tableName.toLowerCase()));
+ repository.delete(NewNodePathGenerator.generatePath(new TableMetadataNodePath(databaseName, schemaName, tableName.toLowerCase()), false));
}
/**
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableRowDataPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableRowDataPersistService.java
index e344edc550d..8d3338e46f6 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableRowDataPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/TableRowDataPersistService.java
@@ -24,9 +24,8 @@ import org.apache.shardingsphere.infra.metadata.statistics.TableStatistics;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.data.pojo.YamlRowStatistics;
import org.apache.shardingsphere.infra.yaml.data.swapper.YamlRowStatisticsSwapper;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsTableNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsTableRowNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.statistics.StatisticsDataNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import java.util.ArrayList;
@@ -50,9 +49,9 @@ public final class TableRowDataPersistService {
*/
public void persist(final String databaseName, final String schemaName, final String tableName, final Collection<YamlRowStatistics> rows) {
if (rows.isEmpty()) {
- repository.persist(new NodePathGenerator(new StatisticsTableNodePath(databaseName, schemaName)).getPath(tableName.toLowerCase()), "");
+ repository.persist(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, tableName.toLowerCase(), null), false), "");
} else {
- rows.forEach(each -> repository.persist(new NodePathGenerator(new StatisticsTableRowNodePath(databaseName, schemaName, tableName.toLowerCase())).getPath(each.getUniqueKey()),
+ rows.forEach(each -> repository.persist(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, tableName.toLowerCase(), each.getUniqueKey()), false),
YamlEngine.marshal(each)));
}
}
@@ -66,7 +65,7 @@ public final class TableRowDataPersistService {
* @param rows rows
*/
public void delete(final String databaseName, final String schemaName, final String tableName, final Collection<YamlRowStatistics> rows) {
- rows.forEach(each -> repository.delete(new NodePathGenerator(new StatisticsTableRowNodePath(databaseName, schemaName, tableName.toLowerCase())).getPath(each.getUniqueKey())));
+ rows.forEach(each -> repository.delete(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, tableName.toLowerCase(), each.getUniqueKey()), false)));
}
/**
@@ -80,8 +79,8 @@ public final class TableRowDataPersistService {
public TableStatistics load(final String databaseName, final String schemaName, final ShardingSphereTable table) {
TableStatistics result = new TableStatistics(table.getName());
YamlRowStatisticsSwapper swapper = new YamlRowStatisticsSwapper(new ArrayList<>(table.getAllColumns()));
- for (String each : repository.getChildrenKeys(new NodePathGenerator(new StatisticsTableNodePath(databaseName, schemaName)).getPath(table.getName()))) {
- String yamlRow = repository.query(new NodePathGenerator(new StatisticsTableRowNodePath(databaseName, schemaName, table.getName())).getPath(each));
+ for (String each : repository.getChildrenKeys(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, table.getName(), null), false))) {
+ String yamlRow = repository.query(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, table.getName(), each), false));
if (!Strings.isNullOrEmpty(yamlRow)) {
result.getRows().add(swapper.swapToObject(YamlEngine.unmarshal(yamlRow, YamlRowStatistics.class)));
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/ViewMetaDataPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/ViewMetaDataPersistService.java
index 9c253e07f9f..6f77c809467 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/ViewMetaDataPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/metadata/service/ViewMetaDataPersistService.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereView;
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlViewSwapper;
import org.apache.shardingsphere.mode.metadata.persist.version.MetaDataVersionPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.metadata.database.ViewNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.metadata.database.ViewMetadataNodePath;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -51,8 +51,8 @@ public final class ViewMetaDataPersistService {
* @return loaded views
*/
public Collection<ShardingSphereView> load(final String databaseName, final String schemaName) {
- return repository.getChildrenKeys(new ViewNodePath(databaseName, schemaName).getRootPath()).stream().map(each -> load(databaseName, schemaName, each))
- .collect(Collectors.toList());
+ return repository.getChildrenKeys(NewNodePathGenerator.generatePath(new ViewMetadataNodePath(databaseName, schemaName, null), false)).stream()
+ .map(each -> load(databaseName, schemaName, each)).collect(Collectors.toList());
}
/**
@@ -64,7 +64,7 @@ public final class ViewMetaDataPersistService {
* @return loaded view
*/
public ShardingSphereView load(final String databaseName, final String schemaName, final String viewName) {
- VersionNodePath versionNodePath = new NodePathGenerator(new ViewNodePath(databaseName, schemaName)).getVersion(viewName);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new ViewMetadataNodePath(databaseName, schemaName, viewName));
int activeVersion = Integer.parseInt(repository.query(versionNodePath.getActiveVersionPath()));
String view = repository.query(versionNodePath.getVersionPath(activeVersion));
return swapper.swapToObject(YamlEngine.unmarshal(view, YamlShardingSphereView.class));
@@ -80,7 +80,7 @@ public final class ViewMetaDataPersistService {
public void persist(final String databaseName, final String schemaName, final Collection<ShardingSphereView> views) {
for (ShardingSphereView each : views) {
String viewName = each.getName().toLowerCase();
- VersionNodePath versionNodePath = new NodePathGenerator(new ViewNodePath(databaseName, schemaName)).getVersion(viewName);
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new ViewMetadataNodePath(databaseName, schemaName, viewName));
metaDataVersionPersistService.persist(versionNodePath, YamlEngine.marshal(swapper.swapToYamlConfiguration(each)));
}
}
@@ -93,6 +93,6 @@ public final class ViewMetaDataPersistService {
* @param viewName to be dropped view name
*/
public void drop(final String databaseName, final String schemaName, final String viewName) {
- repository.delete(new NodePathGenerator(new ViewNodePath(databaseName, schemaName)).getPath(viewName.toLowerCase()));
+ repository.delete(NewNodePathGenerator.generatePath(new ViewMetadataNodePath(databaseName, schemaName, viewName.toLowerCase()), false));
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistService.java
index 1c0cc37f562..e7b498b0e57 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistService.java
@@ -26,10 +26,8 @@ import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatist
import org.apache.shardingsphere.infra.yaml.data.pojo.YamlRowStatistics;
import org.apache.shardingsphere.infra.yaml.data.swapper.YamlRowStatisticsSwapper;
import org.apache.shardingsphere.mode.metadata.persist.metadata.service.TableRowDataPersistService;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsDatabaseNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsSchemaNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsTableNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.statistics.StatisticsDataNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import java.util.ArrayList;
@@ -57,7 +55,7 @@ public final class StatisticsPersistService {
* @return statistics
*/
public ShardingSphereStatistics load(final ShardingSphereMetaData metaData) {
- Collection<String> databaseNames = repository.getChildrenKeys(new StatisticsDatabaseNodePath().getRootPath());
+ Collection<String> databaseNames = repository.getChildrenKeys(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(null, null, null, null), false));
if (databaseNames.isEmpty()) {
return new ShardingSphereStatistics();
}
@@ -70,7 +68,8 @@ public final class StatisticsPersistService {
private DatabaseStatistics load(final ShardingSphereDatabase database) {
DatabaseStatistics result = new DatabaseStatistics();
- for (String each : repository.getChildrenKeys(new StatisticsSchemaNodePath(database.getName()).getRootPath()).stream().filter(database::containsSchema).collect(Collectors.toList())) {
+ for (String each : repository.getChildrenKeys(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(database.getName(), null, null, null), false)).stream()
+ .filter(database::containsSchema).collect(Collectors.toList())) {
result.putSchemaStatistics(each, load(database.getName(), database.getSchema(each)));
}
return result;
@@ -78,8 +77,8 @@ public final class StatisticsPersistService {
private SchemaStatistics load(final String databaseName, final ShardingSphereSchema schema) {
SchemaStatistics result = new SchemaStatistics();
- for (String each : repository.getChildrenKeys(new StatisticsTableNodePath(databaseName, schema.getName()).getRootPath()).stream().filter(schema::containsTable)
- .collect(Collectors.toList())) {
+ for (String each : repository.getChildrenKeys(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", "foo_schema", null, null), false)).stream()
+ .filter(schema::containsTable).collect(Collectors.toList())) {
result.putTableStatistics(each, tableRowDataPersistService.load(databaseName, schema.getName(), schema.getTable(each)));
}
@@ -101,7 +100,7 @@ public final class StatisticsPersistService {
}
private void persistSchema(final String databaseName, final String schemaName) {
- repository.persist(new NodePathGenerator(new StatisticsSchemaNodePath(databaseName)).getPath(schemaName), "");
+ repository.persist(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, schemaName, null, null), true), "");
}
private void persistTableData(final ShardingSphereDatabase database, final String schemaName, final SchemaStatistics schemaStatistics) {
@@ -136,6 +135,6 @@ public final class StatisticsPersistService {
* @param databaseName database name
*/
public void delete(final String databaseName) {
- repository.delete(new NodePathGenerator(new StatisticsDatabaseNodePath()).getPath(databaseName));
+ repository.delete(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(databaseName, null, null, null), true));
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/cluster/ClusterStatePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/cluster/ClusterStatePersistService.java
index 26e37ff48c2..a2f129d7b17 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/cluster/ClusterStatePersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/cluster/ClusterStatePersistService.java
@@ -19,7 +19,8 @@ package org.apache.shardingsphere.mode.state.cluster;
import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.state.cluster.ClusterNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.state.ClusterNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
/**
@@ -36,7 +37,7 @@ public final class ClusterStatePersistService {
* @param state to be updated cluster state
*/
public void update(final ClusterState state) {
- repository.persist(new ClusterNodePath().getRootPath(), state.name());
+ repository.persist(NewNodePathGenerator.generatePath(new ClusterNodePath(), false), state.name());
}
/**
@@ -45,7 +46,7 @@ public final class ClusterStatePersistService {
* @return loaded cluster state
*/
public ClusterState load() {
- String value = repository.query(new ClusterNodePath().getRootPath());
+ String value = repository.query(NewNodePathGenerator.generatePath(new ClusterNodePath(), false));
return Strings.isNullOrEmpty(value) ? ClusterState.OK : ClusterState.valueOf(value);
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/ComputeNodePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/ComputeNodePersistService.java
index c43e8b91089..3159ec52c10 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/ComputeNodePersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/ComputeNodePersistService.java
@@ -29,10 +29,9 @@ import org.apache.shardingsphere.infra.instance.yaml.YamlComputeNodeData;
import org.apache.shardingsphere.infra.instance.yaml.YamlComputeNodeDataSwapper;
import org.apache.shardingsphere.infra.state.instance.InstanceState;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.compute.label.LabelNodePath;
-import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineInstanceNodePath;
-import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineTypeNodePath;
+import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.status.StatusNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.workerid.ComputeNodeWorkerIDNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -68,7 +67,7 @@ public final class ComputeNodePersistService {
private void persistOnline(final ComputeNodeInstance computeNodeInstance) {
ComputeNodeData computeNodeData = new ComputeNodeData(
computeNodeInstance.getMetaData().getDatabaseName(), computeNodeInstance.getMetaData().getAttributes(), computeNodeInstance.getMetaData().getVersion());
- repository.persistEphemeral(new NodePathGenerator(new OnlineInstanceNodePath(computeNodeInstance.getMetaData().getType())).getPath(computeNodeInstance.getMetaData().getId()),
+ repository.persistEphemeral(NewNodePathGenerator.generatePath(new OnlineNodePath(computeNodeInstance.getMetaData().getType(), computeNodeInstance.getMetaData().getId()), false),
YamlEngine.marshal(new YamlComputeNodeDataSwapper().swapToYamlConfiguration(computeNodeData)));
}
@@ -78,7 +77,7 @@ public final class ComputeNodePersistService {
* @param computeNodeInstance compute node instance
*/
public void offline(final ComputeNodeInstance computeNodeInstance) {
- repository.delete(new NodePathGenerator(new OnlineInstanceNodePath(computeNodeInstance.getMetaData().getType())).getPath(computeNodeInstance.getMetaData().getId()));
+ repository.delete(NewNodePathGenerator.generatePath(new OnlineNodePath(computeNodeInstance.getMetaData().getType(), computeNodeInstance.getMetaData().getId()), false));
}
/**
@@ -92,12 +91,10 @@ public final class ComputeNodePersistService {
private Collection<ComputeNodeInstance> loadInstances(final InstanceType instanceType) {
Collection<ComputeNodeInstance> result = new LinkedList<>();
- for (String each : repository.getChildrenKeys(new NodePathGenerator(new OnlineTypeNodePath()).getPath(instanceType.name().toLowerCase()))) {
- String value = repository.query(new NodePathGenerator(new OnlineInstanceNodePath(instanceType)).getPath(each));
+ for (String each : repository.getChildrenKeys(NewNodePathGenerator.generatePath(new OnlineNodePath(instanceType, null), false))) {
+ String value = repository.query(NewNodePathGenerator.generatePath(new OnlineNodePath(instanceType, each), false));
if (!Strings.isNullOrEmpty(value)) {
- ComputeNodeData computeNodeData = new YamlComputeNodeDataSwapper().swapToObject(YamlEngine.unmarshal(value, YamlComputeNodeData.class));
- ComputeNodeInstance instance = loadInstance(InstanceMetaDataFactory.create(each, instanceType, computeNodeData));
- result.add(instance);
+ result.add(loadInstance(InstanceMetaDataFactory.create(each, instanceType, new YamlComputeNodeDataSwapper().swapToObject(YamlEngine.unmarshal(value, YamlComputeNodeData.class)))));
}
}
return result;
@@ -118,12 +115,12 @@ public final class ComputeNodePersistService {
}
private String loadState(final String instanceId) {
- return repository.query(new NodePathGenerator(new StatusNodePath()).getPath(instanceId));
+ return repository.query(NewNodePathGenerator.generatePath(new StatusNodePath(instanceId), false));
}
@SuppressWarnings("unchecked")
private Collection<String> loadLabels(final String instanceId) {
- String yamlContent = repository.query(new NodePathGenerator(new LabelNodePath()).getPath(instanceId));
+ String yamlContent = repository.query(NewNodePathGenerator.generatePath(new LabelNodePath(instanceId), false));
return Strings.isNullOrEmpty(yamlContent) ? Collections.emptyList() : YamlEngine.unmarshal(yamlContent, Collection.class);
}
@@ -134,7 +131,7 @@ public final class ComputeNodePersistService {
* @param instanceState instance state
*/
public void updateState(final String instanceId, final InstanceState instanceState) {
- repository.persistEphemeral(new NodePathGenerator(new StatusNodePath()).getPath(instanceId), instanceState.name());
+ repository.persistEphemeral(NewNodePathGenerator.generatePath(new StatusNodePath(instanceId), false), instanceState.name());
}
/**
@@ -144,7 +141,7 @@ public final class ComputeNodePersistService {
* @param labels instance labels
*/
public void persistLabels(final String instanceId, final Collection<String> labels) {
- repository.persistEphemeral(new NodePathGenerator(new LabelNodePath()).getPath(instanceId), YamlEngine.marshal(labels));
+ repository.persistEphemeral(NewNodePathGenerator.generatePath(new LabelNodePath(instanceId), false), YamlEngine.marshal(labels));
}
/**
@@ -154,7 +151,7 @@ public final class ComputeNodePersistService {
* @param workerId worker ID
*/
public void persistWorkerId(final String instanceId, final int workerId) {
- repository.persistEphemeral(new NodePathGenerator(new ComputeNodeWorkerIDNodePath()).getPath(instanceId), String.valueOf(workerId));
+ repository.persistEphemeral(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath(instanceId), false), String.valueOf(workerId));
}
/**
@@ -165,7 +162,7 @@ public final class ComputeNodePersistService {
*/
public Optional<Integer> loadWorkerId(final String instanceId) {
try {
- String workerId = repository.query(new NodePathGenerator(new ComputeNodeWorkerIDNodePath()).getPath(instanceId));
+ String workerId = repository.query(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath(instanceId), false));
return Strings.isNullOrEmpty(workerId) ? Optional.empty() : Optional.of(Integer.valueOf(workerId));
} catch (final NumberFormatException ex) {
log.error("Invalid worker id for instance: {}", instanceId);
@@ -179,8 +176,8 @@ public final class ComputeNodePersistService {
* @return assigned worker IDs
*/
public Collection<Integer> getAssignedWorkerIds() {
- Collection<String> instanceIds = repository.getChildrenKeys(new ComputeNodeWorkerIDNodePath().getRootPath());
- return instanceIds.stream()
- .map(each -> repository.query(new NodePathGenerator(new ComputeNodeWorkerIDNodePath()).getPath(each))).filter(Objects::nonNull).map(Integer::parseInt).collect(Collectors.toSet());
+ Collection<String> instanceIds = repository.getChildrenKeys(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath(null), false));
+ return instanceIds.stream().map(each -> repository.query(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath(each), false)))
+ .filter(Objects::nonNull).map(Integer::parseInt).collect(Collectors.toSet());
}
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/QualifiedDataSourceStatePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/QualifiedDataSourceStatePersistService.java
index c2ddbcfc863..22a5ed156cb 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/QualifiedDataSourceStatePersistService.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/state/node/QualifiedDataSourceStatePersistService.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.state.datasource.qualified.QualifiedDataS
import org.apache.shardingsphere.infra.state.datasource.qualified.yaml.YamlQualifiedDataSourceState;
import org.apache.shardingsphere.infra.state.datasource.qualified.yaml.YamlQualifiedDataSourceStateSwapper;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.storage.QualifiedDataSourceNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -47,10 +47,10 @@ public final class QualifiedDataSourceStatePersistService {
* @return loaded qualified data source states
*/
public Map<String, QualifiedDataSourceState> load() {
- Collection<String> qualifiedDataSourceNodes = repository.getChildrenKeys(new QualifiedDataSourceNodePath().getRootPath());
+ Collection<String> qualifiedDataSourceNodes = repository.getChildrenKeys(NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(null), false));
Map<String, QualifiedDataSourceState> result = new HashMap<>(qualifiedDataSourceNodes.size(), 1F);
qualifiedDataSourceNodes.forEach(each -> {
- String yamlContent = repository.query(new NodePathGenerator(new QualifiedDataSourceNodePath()).getPath(new QualifiedDataSource(each)));
+ String yamlContent = repository.query(NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(new QualifiedDataSource(each)), false));
if (!Strings.isNullOrEmpty(yamlContent)) {
result.put(each, new YamlQualifiedDataSourceStateSwapper().swapToObject(YamlEngine.unmarshal(yamlContent, YamlQualifiedDataSourceState.class)));
}
@@ -68,7 +68,7 @@ public final class QualifiedDataSourceStatePersistService {
*/
public void update(final String databaseName, final String groupName, final String storageUnitName, final DataSourceState dataSourceState) {
QualifiedDataSourceState status = new QualifiedDataSourceState(dataSourceState);
- repository.persist(new NodePathGenerator(new QualifiedDataSourceNodePath()).getPath(new QualifiedDataSource(databaseName, groupName, storageUnitName)),
+ repository.persist(NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(new QualifiedDataSource(databaseName, groupName, storageUnitName)), false),
YamlEngine.marshal(new YamlQualifiedDataSourceStateSwapper().swapToYamlConfiguration(status)));
}
}
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
index fe581d76a97..533658cd875 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
@@ -38,8 +38,6 @@ import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.metadata.database.SchemaNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.junit.jupiter.api.BeforeEach;
@@ -147,7 +145,7 @@ class ContextManagerTest {
when(metaDataContexts.getMetaData().getDatabase("foo_db").getName()).thenReturn("foo_db");
ShardingSphereDatabase database = mockDatabase();
contextManager.reloadSchema(database, "foo_schema", "foo_ds");
- verify(contextManager.getPersistServiceFacade().getRepository()).delete(new NodePathGenerator(new SchemaNodePath("foo_db")).getPath("foo_schema"));
+ verify(contextManager.getPersistServiceFacade().getRepository()).delete("/metadata/foo_db/schemas/foo_schema");
}
@Test
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePath.java
similarity index 70%
copy from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java
copy to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePath.java
index 26a30cc2e34..71445cbf962 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePath.java
@@ -15,19 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.state;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
+package org.apache.shardingsphere.mode.node.path;
/**
- * States node path.
+ * New node path.
*/
-public final class StatesNodePath implements NodePath {
-
- private static final String ROOT_NODE = "/states";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+public interface NewNodePath {
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePathGenerator.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePathGenerator.java
new file mode 100644
index 00000000000..2e2547df5ff
--- /dev/null
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NewNodePathGenerator.java
@@ -0,0 +1,80 @@
+/*
+ * 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 lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.reflection.ReflectionUtils;
+import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * Node path generator.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class NewNodePathGenerator {
+
+ /**
+ * Generate path.
+ *
+ * @param nodePath node path
+ * @param trimEmptyNode whether to trim empty node
+ * @return path
+ */
+ public static String generatePath(final NewNodePath nodePath, final boolean trimEmptyNode) {
+ LinkedList<String> result = new LinkedList<>();
+ String path = nodePath.getClass().getAnnotation(NodePathEntity.class).value();
+ for (String each : path.split("/")) {
+ if (each.contains("$") || each.contains(":")) {
+ Collection<String> nodeSegments = new LinkedList<>();
+ for (String eachSegment : each.split(":")) {
+ if (eachSegment.startsWith("${") && eachSegment.endsWith("}")) {
+ Object fieldValue = ReflectionUtils.getFieldValue(nodePath, eachSegment.substring(2, eachSegment.length() - 1)).orElse(null);
+ // CHECKSTYLE:OFF
+ if (null == fieldValue) {
+ if (trimEmptyNode) {
+ result.removeLast();
+ }
+ return String.join("/", result);
+ }
+ // CHECKSTYLE:ON
+ nodeSegments.add(fieldValue.toString());
+ } else {
+ nodeSegments.add(each);
+ }
+ }
+ result.add(String.join(":", nodeSegments));
+ } else {
+ result.add(each);
+ }
+ }
+ return String.join("/", result);
+ }
+
+ /**
+ * Generate version node path.
+ *
+ * @param nodePath node path
+ * @return version node path
+ */
+ public static VersionNodePath generateVersionPath(final NewNodePath nodePath) {
+ return new VersionNodePath(generatePath(nodePath, false));
+ }
+}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathEntity.java
similarity index 65%
copy from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java
copy to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathEntity.java
index 5c891e51982..7d355fd00c9 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/NodePathEntity.java
@@ -15,19 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.config.global;
+package org.apache.shardingsphere.mode.node.path;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Global props node path.
+ * Node path entity.
*/
-public final class GlobalRuleNodePath implements NodePath {
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NodePathEntity {
- private static final String ROOT_NODE = "/rules";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+ /**
+ * Get repository node path.
+ *
+ * @return repository node path
+ */
+ String value();
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePath.java
index 13bcf3810ac..102c0f63fee 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePath.java
@@ -17,17 +17,16 @@
package org.apache.shardingsphere.mode.node.path.config.global;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Global properties node path.
*/
-public final class GlobalPropertiesNodePath implements NodePath {
-
- private static final String ROOT_NODE = "/props";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+@NodePathEntity("/props")
+@RequiredArgsConstructor
+@Getter
+public final class GlobalPropertiesNodePath implements NewNodePath {
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathParser.java
index a9cf3b38798..146c191885d 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathParser.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mode.node.path.config.global;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
/**
@@ -27,7 +28,7 @@ import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class GlobalPropertiesNodePathParser {
- private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(new GlobalPropertiesNodePath().getRootPath());
+ private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(NewNodePathGenerator.generatePath(new GlobalPropertiesNodePath(), false));
/**
* Get properties version node path parser.
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java
index 5c891e51982..31c5b4bd67d 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePath.java
@@ -17,17 +17,18 @@
package org.apache.shardingsphere.mode.node.path.config.global;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * Global props node path.
+ * Global rule node path.
*/
-public final class GlobalRuleNodePath implements NodePath {
+@NodePathEntity("/rules/${ruleType}")
+@RequiredArgsConstructor
+@Getter
+public final class GlobalRuleNodePath implements NewNodePath {
- private static final String ROOT_NODE = "/rules";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+ private final String ruleType;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathParser.java
index 20c6dbf2230..5ecae497c8a 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathParser.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mode.node.path.config.global;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@@ -28,7 +29,7 @@ import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class GlobalRuleNodePathParser {
- private static final VersionNodePathParser PARSER = new VersionNodePathParser(new GlobalRuleNodePath().getRootPath() + "/" + NodePathPattern.IDENTIFIER);
+ private static final VersionNodePathParser PARSER = new VersionNodePathParser(NewNodePathGenerator.generatePath(new GlobalRuleNodePath(NodePathPattern.IDENTIFIER), false));
/**
* Get global rule version node path parser.
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePath.java
similarity index 68%
copy from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java
copy to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePath.java
index e9133b7edd8..c0adaa9a1a4 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePath.java
@@ -17,17 +17,20 @@
package org.apache.shardingsphere.mode.node.path.execution;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Execution node path.
*/
-public final class ExecutionNodePath implements NodePath {
+@NodePathEntity("/execution_nodes/${processId}/${instanceId}")
+@RequiredArgsConstructor
+@Getter
+public final class ProcessNodePath implements NewNodePath {
- private static final String ROOT_NODE = "/execution_nodes";
+ private final String processId;
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+ private final String instanceId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePath.java
deleted file mode 100644
index f8392e02a43..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePath.java
+++ /dev/null
@@ -1,46 +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.database;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-import org.apache.shardingsphere.mode.node.path.metadata.DatabaseNodePath;
-
-/**
- * Schema node path.
- */
-@RequiredArgsConstructor
-public final class SchemaNodePath implements NodePath {
-
- private static final String SCHEMAS_NODE = "schemas";
-
- private final String databaseName;
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new DatabaseNodePath());
-
- public SchemaNodePath() {
- this(NodePathPattern.IDENTIFIER);
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(databaseName), SCHEMAS_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathParser.java
index bdcd85839d6..a245de4df80 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathParser.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.node.path.metadata.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import java.util.Optional;
@@ -41,7 +41,8 @@ public final class SchemaNodePathParser {
*/
public static Optional<String> findSchemaName(final String path, final boolean containsChildPath) {
String endPattern = containsChildPath ? "?" : "$";
- Pattern pattern = Pattern.compile(new NodePathGenerator(new SchemaNodePath()).getPath(NodePathPattern.IDENTIFIER) + endPattern, Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(
+ NewNodePathGenerator.generatePath(new TableMetadataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, null), true) + endPattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(path);
return matcher.find() ? Optional.of(matcher.group(2)) : Optional.empty();
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathTest.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePath.java
similarity index 62%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathTest.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePath.java
index bc7232a2ce3..2fd5103f14d 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/SchemaNodePathTest.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePath.java
@@ -17,15 +17,22 @@
package org.apache.shardingsphere.mode.node.path.metadata.database;
-import org.junit.jupiter.api.Test;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class SchemaNodePathTest {
+/**
+ * Table metadata node path.
+ */
+@NodePathEntity("/metadata/${databaseName}/schemas/${schemaName}/tables/${tableName}")
+@RequiredArgsConstructor
+@Getter
+public final class TableMetadataNodePath implements NewNodePath {
+
+ private final String databaseName;
+
+ private final String schemaName;
- @Test
- void assertGetRootPath() {
- assertThat(new SchemaNodePath("foo_db").getRootPath(), is("/metadata/foo_db/schemas"));
- }
+ private final String tableName;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePath.java
deleted file mode 100644
index 26016c1cce9..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePath.java
+++ /dev/null
@@ -1,48 +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.database;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-/**
- * Table node path.
- */
-public final class TableNodePath implements NodePath {
-
- private static final String TABLES_NODE = "tables";
-
- private final String schemaName;
-
- private final NodePathGenerator nodePathGenerator;
-
- public TableNodePath() {
- this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
- }
-
- public TableNodePath(final String databaseName, final String schemaName) {
- this.schemaName = schemaName;
- nodePathGenerator = new NodePathGenerator(new SchemaNodePath(databaseName));
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(schemaName), TABLES_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathParser.java
index d660b04799b..2baf3e1df34 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathParser.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.node.path.metadata.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@@ -33,9 +33,11 @@ import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TableNodePathParser {
- private static final Pattern PATTERN = Pattern.compile(new NodePathGenerator(new TableNodePath()).getPath(NodePathPattern.IDENTIFIER) + "$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(NewNodePathGenerator.generatePath(
+ new TableMetadataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false) + "$", Pattern.CASE_INSENSITIVE);
- private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(new NodePathGenerator(new TableNodePath()).getPath(NodePathPattern.IDENTIFIER));
+ private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(
+ NewNodePathGenerator.generatePath(new TableMetadataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false));
/**
* Find table name.
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathTest.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePath.java
similarity index 62%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathTest.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePath.java
index 2b5cb9bd3a2..2e91eae66b0 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathTest.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePath.java
@@ -17,15 +17,22 @@
package org.apache.shardingsphere.mode.node.path.metadata.database;
-import org.junit.jupiter.api.Test;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ViewNodePathTest {
+/**
+ * View metadata node path.
+ */
+@NodePathEntity("/metadata/${databaseName}/schemas/${schemaName}/views/${viewName}")
+@RequiredArgsConstructor
+@Getter
+public final class ViewMetadataNodePath implements NewNodePath {
+
+ private final String databaseName;
+
+ private final String schemaName;
- @Test
- void assertGetRootPath() {
- assertThat(new ViewNodePath("foo_db", "foo_schema").getRootPath(), is("/metadata/foo_db/schemas/foo_schema/views"));
- }
+ private final String viewName;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePath.java
deleted file mode 100644
index 042dab465c9..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePath.java
+++ /dev/null
@@ -1,48 +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.database;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-/**
- * View node path.
- */
-public final class ViewNodePath implements NodePath {
-
- private static final String VIEWS_NODE = "views";
-
- private final String schemaName;
-
- private final NodePathGenerator nodePathGenerator;
-
- public ViewNodePath() {
- this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
- }
-
- public ViewNodePath(final String databaseName, final String schemaName) {
- this.schemaName = schemaName;
- nodePathGenerator = new NodePathGenerator(new SchemaNodePath(databaseName));
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(schemaName), VIEWS_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathParser.java
index f706e2acc3f..52dca0ad8b4 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewNodePathParser.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.node.path.metadata.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@@ -33,9 +33,11 @@ import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ViewNodePathParser {
- private static final Pattern PATTERN = Pattern.compile(new NodePathGenerator(new ViewNodePath()).getPath(NodePathPattern.IDENTIFIER) + "$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(
+ NewNodePathGenerator.generatePath(new ViewMetadataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false) + "$", Pattern.CASE_INSENSITIVE);
- private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(new NodePathGenerator(new ViewNodePath()).getPath(NodePathPattern.IDENTIFIER));
+ private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(
+ NewNodePathGenerator.generatePath(new ViewMetadataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false));
/**
* Get view name.
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePath.java
deleted file mode 100644
index f8d4b5eb2b5..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePath.java
+++ /dev/null
@@ -1,41 +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.rule;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-
-/**
- * Database rule item node path.
- */
-public final class DatabaseRuleItemNodePath implements NodePath {
-
- private final String ruleType;
-
- private final NodePathGenerator nodePathGenerator;
-
- public DatabaseRuleItemNodePath(final String databaseName, final String ruleType) {
- this.ruleType = ruleType;
- nodePathGenerator = new NodePathGenerator(new DatabaseRuleNodePath(databaseName));
- }
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ruleType);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePath.java
index 6db50fe9ae3..52c6a21d63d 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePath.java
@@ -17,25 +17,23 @@
package org.apache.shardingsphere.mode.node.path.metadata.rule;
+import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.metadata.DatabaseNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
+import org.apache.shardingsphere.mode.node.path.config.database.item.DatabaseRuleItem;
/**
* Database rule node path.
*/
+@NodePathEntity("/metadata/${databaseName}/rules/${ruleType}/${databaseRuleItem}")
@RequiredArgsConstructor
-public final class DatabaseRuleNodePath implements NodePath {
-
- private static final String RULE_NODE = "rules";
+@Getter
+public final class DatabaseRuleNodePath implements NewNodePath {
private final String databaseName;
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new DatabaseNodePath());
+ private final String ruleType;
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(databaseName), RULE_NODE);
- }
+ private final DatabaseRuleItem databaseRuleItem;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePath.java
deleted file mode 100644
index e0cab8455d3..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePath.java
+++ /dev/null
@@ -1,46 +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.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-import org.apache.shardingsphere.mode.node.path.metadata.DatabaseNodePath;
-
-/**
- * Data source node path.
- */
-@RequiredArgsConstructor
-public final class DataSourceNodePath implements NodePath {
-
- private static final String DATA_SOURCES_NODE = "data_sources";
-
- private final String databaseName;
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new DatabaseNodePath());
-
- public DataSourceNodePath() {
- this(NodePathPattern.IDENTIFIER);
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(databaseName), DATA_SOURCES_NODE);
- }
-}
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
index 7426b051242..0afa83888ba 100644
--- 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
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.mode.node.path.metadata.storage;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import java.util.regex.Pattern;
@@ -28,7 +30,7 @@ import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DataSourceNodePathParser {
- private static final Pattern PATTERN = Pattern.compile(new DataSourceNodePath().getRootPath() + "?", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(NewNodePathGenerator.generatePath(new StorageUnitNodePath(NodePathPattern.IDENTIFIER, null), true) + "?", Pattern.CASE_INSENSITIVE);
/**
* Is data source path.
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 e73b7a123c9..aef904a6b30 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
@@ -17,29 +17,20 @@
package org.apache.shardingsphere.mode.node.path.metadata.storage;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Storage node node path.
*/
-public final class StorageNodeNodePath implements NodePath {
+@NodePathEntity("/metadata/${databaseName}/data_sources/nodes/${storageNodeName}")
+@RequiredArgsConstructor
+@Getter
+public final class StorageNodeNodePath implements NewNodePath {
- private static final String NODES_NODE = "nodes";
+ private final String databaseName;
- private final NodePathGenerator nodePathGenerator;
-
- public StorageNodeNodePath() {
- this(NodePathPattern.IDENTIFIER);
- }
-
- public StorageNodeNodePath(final String databaseName) {
- nodePathGenerator = new NodePathGenerator(new DataSourceNodePath(databaseName));
- }
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(NODES_NODE);
- }
+ private final String storageNodeName;
}
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
index 1d875e0dffc..a669b6b1bfd 100644
--- 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
@@ -19,7 +19,7 @@ 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.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@@ -33,9 +33,11 @@ import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class StorageNodeNodePathParser {
- private static final Pattern PATTERN = Pattern.compile(new NodePathGenerator(new StorageNodeNodePath()).getPath(NodePathPattern.IDENTIFIER) + "$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(
+ NewNodePathGenerator.generatePath(new StorageNodeNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false) + "$", Pattern.CASE_INSENSITIVE);
- private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(String.join("/", new StorageNodeNodePath().getRootPath(), NodePathPattern.IDENTIFIER));
+ private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(
+ NewNodePathGenerator.generatePath(new StorageNodeNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false));
/**
* Find storage node name.
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 55666c15d6d..94fc4b09fff 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
@@ -17,31 +17,20 @@
package org.apache.shardingsphere.mode.node.path.metadata.storage;
+import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Storage unit node path.
*/
+@NodePathEntity("/metadata/${databaseName}/data_sources/units/${storageUnitName}")
@RequiredArgsConstructor
-public final class StorageUnitNodePath implements NodePath {
+@Getter
+public final class StorageUnitNodePath implements NewNodePath {
- private static final String UNITS_NODE = "units";
+ private final String databaseName;
- private final NodePathGenerator nodePathGenerator;
-
- public StorageUnitNodePath() {
- this(NodePathPattern.IDENTIFIER);
- }
-
- public StorageUnitNodePath(final String databaseName) {
- nodePathGenerator = new NodePathGenerator(new DataSourceNodePath(databaseName));
- }
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(UNITS_NODE);
- }
+ private final String storageUnitName;
}
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
index e645658cd4e..e1e94b78651 100644
--- 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
@@ -19,7 +19,7 @@ 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.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
import org.apache.shardingsphere.mode.node.path.version.VersionNodePathParser;
@@ -33,9 +33,11 @@ import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class StorageUnitNodePathParser {
- private static final Pattern PATTERN = Pattern.compile(new NodePathGenerator(new StorageUnitNodePath()).getPath(NodePathPattern.IDENTIFIER) + "$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(
+ NewNodePathGenerator.generatePath(new StorageUnitNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false) + "$", Pattern.CASE_INSENSITIVE);
- private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(String.join("/", new StorageUnitNodePath().getRootPath(), NodePathPattern.IDENTIFIER));
+ private static final VersionNodePathParser VERSION_PARSER = new VersionNodePathParser(
+ NewNodePathGenerator.generatePath(new StorageUnitNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER), false));
/**
* Find storage unit name.
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePath.java
index bb20bfa9e82..dc60d1efb10 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePath.java
@@ -17,21 +17,18 @@
package org.apache.shardingsphere.mode.node.path.node.compute.label;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Label node path.
*/
-public final class LabelNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/labels/${instanceId}")
+@RequiredArgsConstructor
+@Getter
+public final class LabelNodePath implements NewNodePath {
- private static final String ROOT_NODE = "labels";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String instanceId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePath.java
index c910ec40380..fdd887f9379 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePath.java
@@ -17,21 +17,20 @@
package org.apache.shardingsphere.mode.node.path.node.compute.process;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Kill process trigger node path.
*/
-public final class KillProcessTriggerNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/kill_process_trigger/${instanceId}:${processId}")
+@RequiredArgsConstructor
+@Getter
+public final class KillProcessTriggerNodePath implements NewNodePath {
- private static final String ROOT_NODE = "kill_process_trigger";
+ private final String instanceId;
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String processId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePath.java
index 9bf1d255193..dc098b43494 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePath.java
@@ -17,21 +17,20 @@
package org.apache.shardingsphere.mode.node.path.node.compute.process;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Show process list trigger node path.
*/
-public final class ShowProcessListTriggerNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/show_process_list_trigger/${instanceId}:${taskId}")
+@RequiredArgsConstructor
+@Getter
+public final class ShowProcessListTriggerNodePath implements NewNodePath {
- private static final String ROOT_NODE = "show_process_list_trigger";
+ private final String instanceId;
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String taskId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePath.java
similarity index 61%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePath.java
index 8a1c31caa0b..dec25842e3e 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePath.java
@@ -17,23 +17,24 @@
package org.apache.shardingsphere.mode.node.path.node.compute.status;
-import lombok.RequiredArgsConstructor;
+import lombok.Getter;
import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * Online instance node path.
+ * Online node path.
*/
-@RequiredArgsConstructor
-public final class OnlineInstanceNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/online/${instanceType}/${instanceId}")
+@Getter
+public final class OnlineNodePath implements NewNodePath {
- private final InstanceType instanceType;
+ private final String instanceType;
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new OnlineTypeNodePath());
+ private final String instanceId;
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(instanceType.name().toLowerCase());
+ public OnlineNodePath(final InstanceType instanceType, final String instanceId) {
+ this.instanceType = null == instanceType ? null : instanceType.name().toLowerCase();
+ this.instanceId = instanceId;
}
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePath.java
deleted file mode 100644
index 0d6c8514c95..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePath.java
+++ /dev/null
@@ -1,37 +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.node.compute.status;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
-
-/**
- * Online type node path.
- */
-public final class OnlineTypeNodePath implements NodePath {
-
- private static final String ROOT_NODE = "online";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePath.java
index 4194d236103..fb08041b54b 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePath.java
@@ -17,21 +17,18 @@
package org.apache.shardingsphere.mode.node.path.node.compute.status;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Status node path.
*/
-public final class StatusNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/status/${instanceId}")
+@RequiredArgsConstructor
+@Getter
+public final class StatusNodePath implements NewNodePath {
- private static final String ROOT_NODE = "status";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String instanceId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePath.java
index 22bc4bea1b7..e5a28afda2f 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePath.java
@@ -17,21 +17,18 @@
package org.apache.shardingsphere.mode.node.path.node.compute.workerid;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Compute node worker ID node path.
*/
-public final class ComputeNodeWorkerIDNodePath implements NodePath {
+@NodePathEntity("/nodes/compute_nodes/worker_id/${instanceId}")
+@RequiredArgsConstructor
+@Getter
+public final class ComputeNodeWorkerIDNodePath implements NewNodePath {
- private static final String ROOT_NODE = "worker_id";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ComputeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String instanceId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePath.java
index eb6e1d8f908..498995b33dc 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePath.java
@@ -17,21 +17,19 @@
package org.apache.shardingsphere.mode.node.path.node.storage;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.node.NodeNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Qualified data source node path.
*/
-public final class QualifiedDataSourceNodePath implements NodePath {
+@NodePathEntity("/nodes/qualified_data_sources/${qualifiedDataSource}")
+@RequiredArgsConstructor
+@Getter
+public final class QualifiedDataSourceNodePath implements NewNodePath {
- private static final String ROOT_NODE = "qualified_data_sources";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new NodeNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final QualifiedDataSource qualifiedDataSource;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathParser.java
index 5a73ec81b06..436f0468df8 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathParser.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.mode.node.path.node.storage;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import java.util.Optional;
import java.util.regex.Matcher;
@@ -40,7 +41,8 @@ public final class QualifiedDataSourceNodePathParser {
* @return found qualified data source
*/
public static Optional<QualifiedDataSource> findQualifiedDataSource(final String qualifiedDataSourcePath) {
- Pattern pattern = Pattern.compile(String.join("/", new QualifiedDataSourceNodePath().getRootPath(), QUALIFIED_DATA_SOURCE_PATTERN + "$"), Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(
+ String.join("/", NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(null), false), QUALIFIED_DATA_SOURCE_PATTERN + "$"), Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(qualifiedDataSourcePath);
return matcher.find() ? Optional.of(new QualifiedDataSource(matcher.group(1))) : Optional.empty();
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePath.java
similarity index 66%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePath.java
index 3798fc41af3..008fc02e5e2 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePath.java
@@ -17,17 +17,18 @@
package org.apache.shardingsphere.mode.node.path.reservation;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * Reservation node path.
+ * Worker ID reservation node path.
*/
-public final class ReservationNodePath implements NodePath {
+@NodePathEntity("/reservation/worker_id/${preselectedWorkerId}")
+@RequiredArgsConstructor
+@Getter
+public final class WorkerIDReservationNodePath implements NewNodePath {
- private static final String ROOT_NODE = "/reservation";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+ private final Integer preselectedWorkerId;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePath.java
deleted file mode 100644
index 6a70949f0b3..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePath.java
+++ /dev/null
@@ -1,37 +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.reservation.workerid;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.reservation.ReservationNodePath;
-
-/**
- * Worker ID reservation node path.
- */
-public final class WorkerIDReservationNodePath implements NodePath {
-
- private static final String ROOT_NODE = "worker_id";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ReservationNodePath());
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(ROOT_NODE));
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePath.java
similarity index 75%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePath.java
index 26a30cc2e34..a7b98fe2fcc 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePath.java
@@ -17,17 +17,12 @@
package org.apache.shardingsphere.mode.node.path.state;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * States node path.
+ * Cluster node path.
*/
-public final class StatesNodePath implements NodePath {
-
- private static final String ROOT_NODE = "/states";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+@NodePathEntity("/states/cluster_state")
+public final class ClusterNodePath implements NewNodePath {
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePath.java
similarity index 62%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePath.java
index 9e4d357ef76..dbd548dc1d1 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePath.java
@@ -15,23 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.state.database;
+package org.apache.shardingsphere.mode.node.path.state;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.state.StatesNodePath;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
* Database listener coordinator node path.
*/
-public final class DatabaseListenerCoordinatorNodePath implements NodePath {
+@NodePathEntity("/states/database_listener_coordinator/${databaseName}")
+@RequiredArgsConstructor
+@Getter
+public final class DatabaseListenerCoordinatorNodePath implements NewNodePath {
- private static final String ROOT_NODE = "database_listener_coordinator";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new StatesNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
+ private final String databaseName;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParser.java
similarity index 84%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParser.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParser.java
index c92d443e128..4a4aa8ef8da 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParser.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.state.database;
+package org.apache.shardingsphere.mode.node.path.state;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import java.util.Optional;
import java.util.regex.Matcher;
@@ -40,7 +40,7 @@ public final class DatabaseListenerCoordinatorNodePathParser {
* @return found database name
*/
public static Optional<String> findDatabaseName(final String databaseListenerCoordinatorNodePath) {
- Pattern pattern = Pattern.compile(new NodePathGenerator(new DatabaseListenerCoordinatorNodePath()).getPath(DATABASE_PATTERN) + "$", Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath(DATABASE_PATTERN), false) + "$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(databaseListenerCoordinatorNodePath);
return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty();
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePath.java
deleted file mode 100644
index 4758ed46093..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePath.java
+++ /dev/null
@@ -1,37 +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.state.cluster;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.state.StatesNodePath;
-
-/**
- * Cluster node path.
- */
-public final class ClusterNodePath implements NodePath {
-
- private static final String ROOT_NODE = "cluster_state";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new StatesNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(ROOT_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePath.java
similarity index 59%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePath.java
index 9734f1c8922..577f4d3409f 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePath.java
@@ -15,25 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.execution.process;
+package org.apache.shardingsphere.mode.node.path.statistics;
+import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.execution.ExecutionNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * Process node path.
+ * Statistics data node path.
*/
+@NodePathEntity("/statistics/databases/${databaseName}/schemas/${schemaName}/tables/${tableName}/${uniqueKey}")
@RequiredArgsConstructor
-public final class ProcessNodePath implements NodePath {
+@Getter
+public final class StatisticsDataNodePath implements NewNodePath {
- private final String processId;
+ private final String databaseName;
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new ExecutionNodePath());
+ private final String schemaName;
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(processId));
- }
+ private final String tableName;
+
+ private final String uniqueKey;
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePath.java
similarity index 69%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePath.java
index e9133b7edd8..c6f73650f64 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePath.java
@@ -15,19 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.execution;
+package org.apache.shardingsphere.mode.node.path.statistics;
-import org.apache.shardingsphere.mode.node.path.NodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePath;
+import org.apache.shardingsphere.mode.node.path.NodePathEntity;
/**
- * Execution node path.
+ * Statistics job node path.
*/
-public final class ExecutionNodePath implements NodePath {
-
- private static final String ROOT_NODE = "/execution_nodes";
-
- @Override
- public String getRootPath() {
- return ROOT_NODE;
- }
+@NodePathEntity("/statistics/job")
+public final class StatisticsJobNodePath implements NewNodePath {
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsNodePathParser.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsNodePathParser.java
index d952f1dbbad..7b4e5b661c0 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsNodePathParser.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsNodePathParser.java
@@ -19,12 +19,8 @@ package org.apache.shardingsphere.mode.node.path.statistics;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsDatabaseNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsSchemaNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsTableNodePath;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsTableRowNodePath;
import java.util.Optional;
import java.util.regex.Matcher;
@@ -47,7 +43,7 @@ public final class StatisticsNodePathParser {
*/
public static Optional<String> findDatabaseName(final String path, final boolean containsChildPath) {
String endPattern = containsChildPath ? "?" : "$";
- Pattern pattern = Pattern.compile(new NodePathGenerator(new StatisticsDatabaseNodePath()).getPath(NodePathPattern.IDENTIFIER) + endPattern, Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(NodePathPattern.IDENTIFIER, null, null, null), true) + endPattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(path);
return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty();
}
@@ -61,7 +57,8 @@ public final class StatisticsNodePathParser {
*/
public static Optional<String> findSchemaName(final String path, final boolean containsChildPath) {
String endPattern = containsChildPath ? "?" : "$";
- Pattern pattern = Pattern.compile(new NodePathGenerator(new StatisticsSchemaNodePath()).getPath(NodePathPattern.IDENTIFIER) + endPattern, Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(
+ NewNodePathGenerator.generatePath(new StatisticsDataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, null, null), true) + endPattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(path);
return matcher.find() ? Optional.of(matcher.group(2)) : Optional.empty();
}
@@ -75,7 +72,9 @@ public final class StatisticsNodePathParser {
*/
public static Optional<String> findTableName(final String path, final boolean containsChildPath) {
String endPattern = containsChildPath ? "?" : "$";
- Pattern pattern = Pattern.compile(new NodePathGenerator(new StatisticsTableNodePath()).getPath(NodePathPattern.IDENTIFIER) + endPattern, Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(
+ NewNodePathGenerator.generatePath(new StatisticsDataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, null), false) + endPattern,
+ Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(path);
return matcher.find() ? Optional.of(matcher.group(3)) : Optional.empty();
}
@@ -87,7 +86,8 @@ public final class StatisticsNodePathParser {
* @return found row unique key
*/
public static Optional<String> findRowUniqueKey(final String path) {
- Pattern pattern = Pattern.compile(new NodePathGenerator(new StatisticsTableRowNodePath()).getPath(UNIQUE_KEY_PATTERN) + "$", Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(NewNodePathGenerator.generatePath(
+ new StatisticsDataNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, UNIQUE_KEY_PATTERN), false) + "$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(path);
return matcher.find() ? Optional.of(matcher.group(4)) : Optional.empty();
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePath.java
deleted file mode 100644
index 7e61ef2ef01..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePath.java
+++ /dev/null
@@ -1,37 +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.statistics.database;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.statistics.StatisticsNodePath;
-
-/**
- * Statistics database node path.
- */
-public final class StatisticsDatabaseNodePath implements NodePath {
-
- private static final String DATABASES_NODE = "databases";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new StatisticsNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(DATABASES_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePath.java
deleted file mode 100644
index 2261e19b013..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePath.java
+++ /dev/null
@@ -1,45 +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.statistics.database;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-/**
- * Statistics schema node path.
- */
-@RequiredArgsConstructor
-public final class StatisticsSchemaNodePath implements NodePath {
-
- private static final String SCHEMAS_NODE = "schemas";
-
- private final String databaseName;
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new StatisticsDatabaseNodePath());
-
- public StatisticsSchemaNodePath() {
- this(NodePathPattern.IDENTIFIER);
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(databaseName), SCHEMAS_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePath.java
deleted file mode 100644
index 61984fc990e..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePath.java
+++ /dev/null
@@ -1,48 +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.statistics.database;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-/**
- * Statistics table node path.
- */
-public final class StatisticsTableNodePath implements NodePath {
-
- private static final String TABLES_NODE = "tables";
-
- private final String schemaName;
-
- private final NodePathGenerator nodePathGenerator;
-
- public StatisticsTableNodePath(final String databaseName, final String schemaName) {
- this.schemaName = schemaName;
- nodePathGenerator = new NodePathGenerator(new StatisticsSchemaNodePath(databaseName));
- }
-
- public StatisticsTableNodePath() {
- this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
- }
-
- @Override
- public String getRootPath() {
- return String.join("/", nodePathGenerator.getPath(schemaName), TABLES_NODE);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePath.java
deleted file mode 100644
index 430d51ae0ac..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePath.java
+++ /dev/null
@@ -1,46 +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.statistics.database;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.NodePathPattern;
-
-/**
- * Statistics table row node path.
- */
-public final class StatisticsTableRowNodePath implements NodePath {
-
- private final String tableName;
-
- private final NodePathGenerator nodePathGenerator;
-
- public StatisticsTableRowNodePath(final String databaseName, final String schemaName, final String tableName) {
- this.tableName = tableName;
- nodePathGenerator = new NodePathGenerator(new StatisticsTableNodePath(databaseName, schemaName));
- }
-
- public StatisticsTableRowNodePath() {
- this(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER);
- }
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(tableName);
- }
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePath.java
deleted file mode 100644
index 397c110815f..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePath.java
+++ /dev/null
@@ -1,37 +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.statistics.job;
-
-import org.apache.shardingsphere.mode.node.path.NodePath;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.statistics.StatisticsNodePath;
-
-/**
- * Statistics job node path generator.
- */
-public final class StatisticsJobNodePath implements NodePath {
-
- private static final String JOB_NODE = "job";
-
- private final NodePathGenerator nodePathGenerator = new NodePathGenerator(new StatisticsNodePath());
-
- @Override
- public String getRootPath() {
- return nodePathGenerator.getPath(JOB_NODE);
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathTest.java
index f4a01124e66..046643ea573 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalPropertiesNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.config.global;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class GlobalPropertiesNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new GlobalPropertiesNodePath().getRootPath(), is("/props"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new GlobalPropertiesNodePath(), false), is("/props"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathTest.java
index 0d6b387ddf4..e64abaa614b 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/global/GlobalRuleNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.config.global;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
class GlobalRuleNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new GlobalRuleNodePath().getRootPath(), is("/rules"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new GlobalRuleNodePath(null), false), is("/rules"));
+ assertThat(NewNodePathGenerator.generatePath(new GlobalRuleNodePath("foo_rule"), false), is("/rules/foo_rule"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePathTest.java
similarity index 69%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePathTest.java
index 59a74a56559..05c2e484085 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ExecutionNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/ProcessNodePathTest.java
@@ -17,15 +17,17 @@
package org.apache.shardingsphere.mode.node.path.execution;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class ExecutionNodePathTest {
+class ProcessNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new ExecutionNodePath().getRootPath(), is("/execution_nodes"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new ProcessNodePath("foo_process_id", null), false), is("/execution_nodes/foo_process_id"));
+ assertThat(NewNodePathGenerator.generatePath(new ProcessNodePath("foo_process_id", "foo_instance_id"), false), is("/execution_nodes/foo_process_id/foo_instance_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePathTest.java
deleted file mode 100644
index c64632f8388..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/execution/process/ProcessNodePathTest.java
+++ /dev/null
@@ -1,31 +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.execution.process;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ProcessNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new ProcessNodePath("foo_process_id").getRootPath(), is("/execution_nodes/foo_process_id"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePathTest.java
new file mode 100644
index 00000000000..59b8c753088
--- /dev/null
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableMetadataNodePathTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.database;
+
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class TableMetadataNodePathTest {
+
+ @Test
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new TableMetadataNodePath("foo_db", null, null), false), is("/metadata/foo_db/schemas"));
+ assertThat(NewNodePathGenerator.generatePath(new TableMetadataNodePath("foo_db", "foo_schema", null), false), is("/metadata/foo_db/schemas/foo_schema/tables"));
+ assertThat(NewNodePathGenerator.generatePath(new TableMetadataNodePath("foo_db", "foo_schema", null), true), is("/metadata/foo_db/schemas/foo_schema"));
+ assertThat(NewNodePathGenerator.generatePath(new TableMetadataNodePath("foo_db", "foo_schema", "foo_tbl"), false), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl"));
+ }
+
+ @Test
+ void assertGenerateVersionPath() {
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new TableMetadataNodePath("foo_db", "foo_schema", "foo_tbl"));
+ assertThat(versionNodePath.getActiveVersionPath(), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/active_version"));
+ assertThat(versionNodePath.getVersionsPath(), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions"));
+ assertThat(versionNodePath.getVersionPath(0), is("/metadata/foo_db/schemas/foo_schema/tables/foo_tbl/versions/0"));
+ }
+}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathTest.java
deleted file mode 100644
index b6f366b8632..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/TableNodePathTest.java
+++ /dev/null
@@ -1,31 +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.database;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class TableNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new TableNodePath("foo_db", "foo_schema").getRootPath(), is("/metadata/foo_db/schemas/foo_schema/tables"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePathTest.java
new file mode 100644
index 00000000000..0c38bf55d75
--- /dev/null
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/database/ViewMetadataNodePathTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.database;
+
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class ViewMetadataNodePathTest {
+
+ @Test
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new ViewMetadataNodePath("foo_db", null, null), false), is("/metadata/foo_db/schemas"));
+ assertThat(NewNodePathGenerator.generatePath(new ViewMetadataNodePath("foo_db", "foo_schema", null), false), is("/metadata/foo_db/schemas/foo_schema/views"));
+ assertThat(NewNodePathGenerator.generatePath(new ViewMetadataNodePath("foo_db", "foo_schema", null), true), is("/metadata/foo_db/schemas/foo_schema"));
+ assertThat(NewNodePathGenerator.generatePath(new ViewMetadataNodePath("foo_db", "foo_schema", "foo_view"), false), is("/metadata/foo_db/schemas/foo_schema/views/foo_view"));
+ }
+
+ @Test
+ void assertGenerateVersionPath() {
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new ViewMetadataNodePath("foo_db", "foo_schema", "foo_view"));
+ assertThat(versionNodePath.getActiveVersionPath(), is("/metadata/foo_db/schemas/foo_schema/views/foo_view/active_version"));
+ assertThat(versionNodePath.getVersionsPath(), is("/metadata/foo_db/schemas/foo_schema/views/foo_view/versions"));
+ assertThat(versionNodePath.getVersionPath(0), is("/metadata/foo_db/schemas/foo_schema/views/foo_view/versions/0"));
+ }
+}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePathTest.java
deleted file mode 100644
index 18a02d69e2f..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleItemNodePathTest.java
+++ /dev/null
@@ -1,31 +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.rule;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class DatabaseRuleItemNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new DatabaseRuleItemNodePath("foo_db", "foo_rule").getRootPath(), is("/metadata/foo_db/rules/foo_rule"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePathTest.java
index b45f4637f07..0205fee4e33 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/rule/DatabaseRuleNodePathTest.java
@@ -17,6 +17,9 @@
package org.apache.shardingsphere.mode.node.path.metadata.rule;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.config.database.item.DatabaseRuleItem;
+import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +28,20 @@ import static org.hamcrest.MatcherAssert.assertThat;
class DatabaseRuleNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new DatabaseRuleNodePath("foo_db").getRootPath(), is("/metadata/foo_db/rules"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath("foo_db", null, null), false), is("/metadata/foo_db/rules"));
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath("foo_db", "foo_rule", null), false), is("/metadata/foo_db/rules/foo_rule"));
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath("foo_db", "foo_rule", new DatabaseRuleItem("unique_rule_item")), false),
+ is("/metadata/foo_db/rules/foo_rule/unique_rule_item"));
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseRuleNodePath("foo_db", "foo_rule", new DatabaseRuleItem("named_rule_item/item")), false),
+ is("/metadata/foo_db/rules/foo_rule/named_rule_item/item"));
+ }
+
+ @Test
+ void assertGenerateVersionPath() {
+ VersionNodePath versionNodePath = NewNodePathGenerator.generateVersionPath(new DatabaseRuleNodePath("foo_db", "foo_rule", new DatabaseRuleItem("named_rule_item/item")));
+ assertThat(versionNodePath.getActiveVersionPath(), is("/metadata/foo_db/rules/foo_rule/named_rule_item/item/active_version"));
+ assertThat(versionNodePath.getVersionsPath(), is("/metadata/foo_db/rules/foo_rule/named_rule_item/item/versions"));
+ assertThat(versionNodePath.getVersionPath(0), is("/metadata/foo_db/rules/foo_rule/named_rule_item/item/versions/0"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathTest.java
deleted file mode 100644
index ae906ee5442..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/metadata/storage/DataSourceNodePathTest.java
+++ /dev/null
@@ -1,31 +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.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class DataSourceNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new DataSourceNodePath("foo_db").getRootPath(), is("/metadata/foo_db/data_sources"));
- }
-}
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 9e27f9c1adb..934a86d1ea9 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
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.metadata.storage;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
class StorageNodeNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new StorageNodeNodePath("foo_db").getRootPath(), is("/metadata/foo_db/data_sources/nodes"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new StorageNodeNodePath("foo_db", null), false), is("/metadata/foo_db/data_sources/nodes"));
+ assertThat(NewNodePathGenerator.generatePath(new StorageNodeNodePath("foo_db", "foo_storage_node"), false), is("/metadata/foo_db/data_sources/nodes/foo_storage_node"));
}
}
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 7ef038de91e..03cffcde865 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
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.metadata.storage;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
class StorageUnitNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new StorageUnitNodePath("foo_db").getRootPath(), is("/metadata/foo_db/data_sources/units"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new StorageUnitNodePath("foo_db", null), false), is("/metadata/foo_db/data_sources/units"));
+ assertThat(NewNodePathGenerator.generatePath(new StorageUnitNodePath("foo_db", "foo_storage_unit"), false), is("/metadata/foo_db/data_sources/units/foo_storage_unit"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePathTest.java
index e7a999bc5b2..bfd98abd046 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/label/LabelNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.node.compute.label;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class LabelNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new LabelNodePath().getRootPath(), is("/nodes/compute_nodes/labels"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new LabelNodePath("foo_instance_id"), false), is("/nodes/compute_nodes/labels/foo_instance_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePathTest.java
index 845ad68acdd..53fa69e6726 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/KillProcessTriggerNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.node.compute.process;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
class KillProcessTriggerNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new KillProcessTriggerNodePath().getRootPath(), is("/nodes/compute_nodes/kill_process_trigger"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath(null, null), false), is("/nodes/compute_nodes/kill_process_trigger"));
+ assertThat(NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath("foo_instance_id", "foo_process_id"), false),
+ is("/nodes/compute_nodes/kill_process_trigger/foo_instance_id:foo_process_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePathTest.java
index 4160d0ab4f2..f5773b54a79 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/process/ShowProcessListTriggerNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.node.compute.process;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
class ShowProcessListTriggerNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new ShowProcessListTriggerNodePath().getRootPath(), is("/nodes/compute_nodes/show_process_list_trigger"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath(null, null), false), is("/nodes/compute_nodes/show_process_list_trigger"));
+ assertThat(NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath("foo_instance_id", "foo_process_id"), false),
+ is("/nodes/compute_nodes/show_process_list_trigger/foo_instance_id:foo_process_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePathTest.java
similarity index 65%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePathTest.java
index 6e8281456c6..8254d963d54 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineInstanceNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineNodePathTest.java
@@ -18,16 +18,18 @@
package org.apache.shardingsphere.mode.node.path.node.compute.status;
import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class OnlineInstanceNodePathTest {
+class OnlineNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new OnlineInstanceNodePath(InstanceType.JDBC).getRootPath(), is("/nodes/compute_nodes/online/jdbc"));
- assertThat(new OnlineInstanceNodePath(InstanceType.PROXY).getRootPath(), is("/nodes/compute_nodes/online/proxy"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new OnlineNodePath(null, null), false), is("/nodes/compute_nodes/online"));
+ assertThat(NewNodePathGenerator.generatePath(new OnlineNodePath(InstanceType.JDBC, null), false), is("/nodes/compute_nodes/online/jdbc"));
+ assertThat(NewNodePathGenerator.generatePath(new OnlineNodePath(InstanceType.PROXY, "foo_instance_id"), false), is("/nodes/compute_nodes/online/proxy/foo_instance_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePathTest.java
deleted file mode 100644
index af293f23d2e..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/OnlineTypeNodePathTest.java
+++ /dev/null
@@ -1,31 +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.node.compute.status;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class OnlineTypeNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new OnlineTypeNodePath().getRootPath(), is("/nodes/compute_nodes/online"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePathTest.java
index 1fd5879f951..d873d958197 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/status/StatusNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.node.compute.status;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
class StatusNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new StatusNodePath().getRootPath(), is("/nodes/compute_nodes/status"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new StatusNodePath(null), false), is("/nodes/compute_nodes/status"));
+ assertThat(NewNodePathGenerator.generatePath(new StatusNodePath("foo_instance_id"), false), is("/nodes/compute_nodes/status/foo_instance_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePathTest.java
index 35e8a0480f3..6f704512f39 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/compute/workerid/ComputeNodeWorkerIDNodePathTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.mode.node.path.node.compute.workerid;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class ComputeNodeWorkerIDNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new ComputeNodeWorkerIDNodePath().getRootPath(), is("/nodes/compute_nodes/worker_id"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath("foo_instance_id"), false), is("/nodes/compute_nodes/worker_id/foo_instance_id"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathTest.java
index 460c3df10d2..ed135d1b288 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/node/storage/QualifiedDataSourceNodePathTest.java
@@ -17,15 +17,18 @@
package org.apache.shardingsphere.mode.node.path.node.storage;
-import org.hamcrest.MatcherAssert;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
class QualifiedDataSourceNodePathTest {
@Test
- void assertGetRootPath() {
- MatcherAssert.assertThat(new QualifiedDataSourceNodePath().getRootPath(), is("/nodes/qualified_data_sources"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(new QualifiedDataSource("foo_db.foo_group.foo_ds")), false),
+ is("/nodes/qualified_data_sources/foo_db.foo_group.foo_ds"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePathTest.java
similarity index 71%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePathTest.java
index 9f316e03228..d3be62296ec 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/ReservationNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/WorkerIDReservationNodePathTest.java
@@ -17,15 +17,17 @@
package org.apache.shardingsphere.mode.node.path.reservation;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class ReservationNodePathTest {
+class WorkerIDReservationNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new ReservationNodePath().getRootPath(), is("/reservation"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new WorkerIDReservationNodePath(null), false), is("/reservation/worker_id"));
+ assertThat(NewNodePathGenerator.generatePath(new WorkerIDReservationNodePath(1), false), is("/reservation/worker_id/1"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePathTest.java
deleted file mode 100644
index a687e7a2538..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/reservation/workerid/WorkerIDReservationNodePathTest.java
+++ /dev/null
@@ -1,31 +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.reservation.workerid;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class WorkerIDReservationNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new WorkerIDReservationNodePath().getRootPath(), is("/reservation/worker_id"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePathTest.java
similarity index 80%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePathTest.java
index 76ae9a5c291..55e55ec9f67 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/StatesNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/ClusterNodePathTest.java
@@ -17,15 +17,16 @@
package org.apache.shardingsphere.mode.node.path.state;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class StatesNodePathTest {
+class ClusterNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new StatesNodePath().getRootPath(), is("/states"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new ClusterNodePath(), false), is("/states/cluster_state"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParserTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParserTest.java
similarity index 95%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParserTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParserTest.java
index 7012f8a4e34..9052627634c 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathParserTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathParserTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.state.database;
+package org.apache.shardingsphere.mode.node.path.state;
import org.junit.jupiter.api.Test;
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathTest.java
similarity index 67%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathTest.java
index f51333e8f5b..82d74ee9fa8 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/database/DatabaseListenerCoordinatorNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/DatabaseListenerCoordinatorNodePathTest.java
@@ -15,8 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.state.database;
+package org.apache.shardingsphere.mode.node.path.state;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
class DatabaseListenerCoordinatorNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new DatabaseListenerCoordinatorNodePath().getRootPath(), is("/states/database_listener_coordinator"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath(null), false), is("/states/database_listener_coordinator"));
+ assertThat(NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath("foo_db"), false), is("/states/database_listener_coordinator/foo_db"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePathTest.java
deleted file mode 100644
index d77195f1ed8..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/state/cluster/ClusterNodePathTest.java
+++ /dev/null
@@ -1,31 +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.state.cluster;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ClusterNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new ClusterNodePath().getRootPath(), is("/states/cluster_state"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePathTest.java
new file mode 100644
index 00000000000..05fb61e1788
--- /dev/null
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsDataNodePathTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.statistics;
+
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class StatisticsDataNodePathTest {
+
+ @Test
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath(null, null, null, null), false), is("/statistics/databases"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", null, null, null), true), is("/statistics/databases/foo_db"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", null, null, null), false), is("/statistics/databases/foo_db/schemas"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", "foo_schema", null, null), true), is("/statistics/databases/foo_db/schemas/foo_schema"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", "foo_schema", null, null), false), is("/statistics/databases/foo_db/schemas/foo_schema/tables"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", "foo_schema", "foo_tbl", null), false),
+ is("/statistics/databases/foo_db/schemas/foo_schema/tables/foo_tbl"));
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsDataNodePath("foo_db", "foo_schema", "foo_tbl", "foo_key"), false),
+ is("/statistics/databases/foo_db/schemas/foo_schema/tables/foo_tbl/foo_key"));
+ }
+}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePathTest.java
similarity index 78%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePathTest.java
index 86978b4b0e3..85ab3d6b39d 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/job/StatisticsJobNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/StatisticsJobNodePathTest.java
@@ -15,8 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.node.path.statistics.job;
+package org.apache.shardingsphere.mode.node.path.statistics;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -25,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class StatisticsJobNodePathTest {
@Test
- void assertGetRootPath() {
- assertThat(new StatisticsJobNodePath().getRootPath(), is("/statistics/job"));
+ void assertGeneratePath() {
+ assertThat(NewNodePathGenerator.generatePath(new StatisticsJobNodePath(), false), is("/statistics/job"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePathTest.java
deleted file mode 100644
index e050dd0de19..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsDatabaseNodePathTest.java
+++ /dev/null
@@ -1,31 +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.statistics.database;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StatisticsDatabaseNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new StatisticsDatabaseNodePath().getRootPath(), is("/statistics/databases"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePathTest.java
deleted file mode 100644
index 4c10480eac7..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsSchemaNodePathTest.java
+++ /dev/null
@@ -1,31 +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.statistics.database;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StatisticsSchemaNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new StatisticsSchemaNodePath("foo_db").getRootPath(), is("/statistics/databases/foo_db/schemas"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePathTest.java
deleted file mode 100644
index 6eda10f5fa9..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableNodePathTest.java
+++ /dev/null
@@ -1,31 +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.statistics.database;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StatisticsTableNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new StatisticsTableNodePath("foo_db", "foo_schema").getRootPath(), is("/statistics/databases/foo_db/schemas/foo_schema/tables"));
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePathTest.java
deleted file mode 100644
index 98cefd912bc..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/statistics/database/StatisticsTableRowNodePathTest.java
+++ /dev/null
@@ -1,31 +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.statistics.database;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StatisticsTableRowNodePathTest {
-
- @Test
- void assertGetRootPath() {
- assertThat(new StatisticsTableRowNodePath("foo_db", "foo_schema", "foo_tbl").getRootPath(), is("/statistics/databases/foo_db/schemas/foo_schema/tables/foo_tbl"));
- }
-}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 45cde9ef679..fa63d5e2570 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
-import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistFacade;
import org.apache.shardingsphere.mode.deliver.DeliverEventSubscriber;
+import org.apache.shardingsphere.mode.deliver.DeliverEventSubscriberRegistry;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.builder.ContextManagerBuilder;
import org.apache.shardingsphere.mode.manager.builder.ContextManagerBuilderParameter;
@@ -35,10 +35,10 @@ import org.apache.shardingsphere.mode.manager.cluster.dispatch.listener.DataChan
import org.apache.shardingsphere.mode.manager.cluster.exception.MissingRequiredClusterRepositoryConfigurationException;
import org.apache.shardingsphere.mode.manager.cluster.lock.ClusterLockContext;
import org.apache.shardingsphere.mode.manager.cluster.lock.GlobalLockPersistService;
-import org.apache.shardingsphere.mode.deliver.DeliverEventSubscriberRegistry;
import org.apache.shardingsphere.mode.manager.cluster.workerid.ClusterWorkerIdGenerator;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistFacade;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -62,7 +62,8 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
computeNodeInstanceContext.init(new ClusterWorkerIdGenerator(repository, param.getInstanceMetaData().getId()), lockContext);
MetaDataContexts metaDataContexts = new MetaDataContextsFactory(new MetaDataPersistFacade(repository), computeNodeInstanceContext).create(param);
ContextManager result = new ContextManager(metaDataContexts, computeNodeInstanceContext, repository);
- registerOnline(computeNodeInstanceContext, param, result, repository);
+ registerOnline(computeNodeInstanceContext, param, result);
+ new DeliverEventSubscriberRegistry(result.getComputeNodeInstanceContext().getEventBusContext()).register(createDeliverEventSubscribers(repository));
return result;
}
@@ -73,14 +74,11 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
return result;
}
- private void registerOnline(final ComputeNodeInstanceContext computeNodeInstanceContext, final ContextManagerBuilderParameter param,
- final ContextManager contextManager, final PersistRepository repository) {
+ private void registerOnline(final ComputeNodeInstanceContext computeNodeInstanceContext, final ContextManagerBuilderParameter param, final ContextManager contextManager) {
contextManager.getPersistServiceFacade().getComputeNodePersistService().registerOnline(computeNodeInstanceContext.getInstance());
contextManager.getComputeNodeInstanceContext().getClusterInstanceRegistry().getAllClusterInstances()
.addAll(contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllInstances());
new DataChangedEventListenerRegistry(contextManager, getDatabaseNames(param, contextManager.getPersistServiceFacade().getMetaDataPersistFacade())).register();
- DeliverEventSubscriberRegistry deliverEventSubscriberRegistry = new DeliverEventSubscriberRegistry(contextManager.getComputeNodeInstanceContext().getEventBusContext());
- deliverEventSubscriberRegistry.register(createDeliverEventSubscribers(repository));
}
private Collection<String> getDatabaseNames(final ContextManagerBuilderParameter param, final MetaDataPersistFacade metaDataPersistFacade) {
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ClusterStateChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ClusterStateChangedHandler.java
index 75e08999ee9..c91e83fbd14 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ClusterStateChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ClusterStateChangedHandler.java
@@ -21,7 +21,8 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
-import org.apache.shardingsphere.mode.node.path.state.cluster.ClusterNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.state.ClusterNodePath;
import org.apache.shardingsphere.mode.state.cluster.ClusterState;
import java.util.Arrays;
@@ -34,7 +35,7 @@ public final class ClusterStateChangedHandler implements GlobalDataChangedEventH
@Override
public String getSubscribedKey() {
- return new ClusterNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new ClusterNodePath(), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeOnlineHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeOnlineHandler.java
index 90367f1fe0a..7af5f58ad73 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeOnlineHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeOnlineHandler.java
@@ -29,7 +29,8 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
-import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineTypeNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineNodePath;
import java.util.Arrays;
import java.util.Collection;
@@ -43,7 +44,7 @@ public final class ComputeNodeOnlineHandler implements GlobalDataChangedEventHan
@Override
public String getSubscribedKey() {
- return new OnlineTypeNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new OnlineNodePath(null, null), false);
}
@Override
@@ -67,6 +68,6 @@ public final class ComputeNodeOnlineHandler implements GlobalDataChangedEventHan
}
private Matcher getInstanceOnlinePathMatcher(final String onlineInstancePath) {
- return Pattern.compile(new OnlineTypeNodePath().getRootPath() + "/([\\S]+)/([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(onlineInstancePath);
+ return Pattern.compile(NewNodePathGenerator.generatePath(new OnlineNodePath(null, null), false) + "/([\\S]+)/([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(onlineInstancePath);
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeStateChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeStateChangedHandler.java
index d720eefc410..b76605473a3 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeStateChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ComputeNodeStateChangedHandler.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.ComputeNodePathParser;
import org.apache.shardingsphere.mode.node.path.node.compute.label.LabelNodePath;
@@ -58,12 +58,12 @@ public final class ComputeNodeStateChangedHandler implements GlobalDataChangedEv
@SuppressWarnings("unchecked")
private void handle(final ContextManager contextManager, final DataChangedEvent event, final String instanceId) {
ComputeNodeInstanceContext computeNodeInstanceContext = contextManager.getComputeNodeInstanceContext();
- if (event.getKey().equals(new NodePathGenerator(new StatusNodePath()).getPath(instanceId)) && Type.DELETED != event.getType()) {
+ if (event.getKey().equals(NewNodePathGenerator.generatePath(new StatusNodePath(instanceId), false)) && Type.DELETED != event.getType()) {
computeNodeInstanceContext.updateStatus(instanceId, event.getValue());
- } else if (event.getKey().equals(new NodePathGenerator(new LabelNodePath()).getPath(instanceId)) && Type.DELETED != event.getType()) {
+ } else if (event.getKey().equals(NewNodePathGenerator.generatePath(new LabelNodePath(instanceId), false)) && Type.DELETED != event.getType()) {
// TODO labels may be empty
computeNodeInstanceContext.updateLabels(instanceId, Strings.isNullOrEmpty(event.getValue()) ? new ArrayList<>() : YamlEngine.unmarshal(event.getValue(), Collection.class));
- } else if (event.getKey().equals(new NodePathGenerator(new ComputeNodeWorkerIDNodePath()).getPath(instanceId))) {
+ } else if (event.getKey().equals(NewNodePathGenerator.generatePath(new ComputeNodeWorkerIDNodePath(instanceId), false))) {
computeNodeInstanceContext.updateWorkerId(instanceId, Strings.isNullOrEmpty(event.getValue()) ? null : Integer.valueOf(event.getValue()));
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/DatabaseListenerChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/DatabaseListenerChangedHandler.java
index e4e52ce094f..7b8086bd42e 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/DatabaseListenerChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/DatabaseListenerChangedHandler.java
@@ -26,10 +26,11 @@ import org.apache.shardingsphere.mode.manager.cluster.dispatch.listener.type.Dat
import org.apache.shardingsphere.mode.manager.cluster.persist.coordinator.database.ClusterDatabaseListenerCoordinatorType;
import org.apache.shardingsphere.mode.manager.cluster.persist.coordinator.database.ClusterDatabaseListenerPersistCoordinator;
import org.apache.shardingsphere.mode.metadata.refresher.statistics.StatisticsRefreshEngine;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
import org.apache.shardingsphere.mode.node.path.metadata.DatabaseNodePath;
-import org.apache.shardingsphere.mode.node.path.state.database.DatabaseListenerCoordinatorNodePathParser;
-import org.apache.shardingsphere.mode.node.path.state.database.DatabaseListenerCoordinatorNodePath;
+import org.apache.shardingsphere.mode.node.path.state.DatabaseListenerCoordinatorNodePathParser;
+import org.apache.shardingsphere.mode.node.path.state.DatabaseListenerCoordinatorNodePath;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import java.util.Arrays;
@@ -42,7 +43,7 @@ public final class DatabaseListenerChangedHandler implements GlobalDataChangedEv
@Override
public String getSubscribedKey() {
- return new DatabaseListenerCoordinatorNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath(null), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/GlobalRuleChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/GlobalRuleChangedHandler.java
index fac2c75b3b0..b72c2d2220a 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/GlobalRuleChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/GlobalRuleChangedHandler.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.checker.ActiveVersionChecker;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalRuleNodePath;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalRuleNodePathParser;
@@ -38,7 +39,7 @@ public final class GlobalRuleChangedHandler implements GlobalDataChangedEventHan
@Override
public String getSubscribedKey() {
- return new GlobalRuleNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new GlobalRuleNodePath(null), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/KillProcessHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/KillProcessHandler.java
index 0e991a14ac3..1e874b1820e 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/KillProcessHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/KillProcessHandler.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
import org.apache.shardingsphere.mode.manager.cluster.persist.coordinator.process.ClusterProcessPersistCoordinator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.compute.process.KillProcessTriggerNodePath;
import java.sql.SQLException;
@@ -40,7 +41,7 @@ public final class KillProcessHandler implements GlobalDataChangedEventHandler {
@Override
public String getSubscribedKey() {
- return new KillProcessTriggerNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath(null, null), false);
}
@Override
@@ -72,6 +73,6 @@ public final class KillProcessHandler implements GlobalDataChangedEventHandler {
}
private Matcher getKillProcessTriggerMatcher(final DataChangedEvent event) {
- return Pattern.compile(new KillProcessTriggerNodePath().getRootPath() + "/([\\S]+):([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(event.getKey());
+ return Pattern.compile(NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath(null, null), false) + "/([\\S]+):([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(event.getKey());
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/PropertiesChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/PropertiesChangedHandler.java
index 91834146afe..e14bf24ee72 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/PropertiesChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/PropertiesChangedHandler.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.checker.ActiveVersionChecker;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalPropertiesNodePath;
import org.apache.shardingsphere.mode.node.path.config.global.GlobalPropertiesNodePathParser;
@@ -35,7 +36,7 @@ public final class PropertiesChangedHandler implements GlobalDataChangedEventHan
@Override
public String getSubscribedKey() {
- return new GlobalPropertiesNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new GlobalPropertiesNodePath(), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/QualifiedDataSourceChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/QualifiedDataSourceChangedHandler.java
index ee57fff9c07..469156731b8 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/QualifiedDataSourceChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/QualifiedDataSourceChangedHandler.java
@@ -30,6 +30,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent;
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.storage.QualifiedDataSourceNodePath;
import org.apache.shardingsphere.mode.node.path.node.storage.QualifiedDataSourceNodePathParser;
@@ -44,7 +45,7 @@ public final class QualifiedDataSourceChangedHandler implements GlobalDataChange
@Override
public String getSubscribedKey() {
- return new QualifiedDataSourceNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new QualifiedDataSourceNodePath(null), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ShowProcessListHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ShowProcessListHandler.java
index 9fb142357ae..34f15a3efa5 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ShowProcessListHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/ShowProcessListHandler.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
import org.apache.shardingsphere.mode.manager.cluster.persist.coordinator.process.ClusterProcessPersistCoordinator;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.node.compute.process.ShowProcessListTriggerNodePath;
import java.util.Arrays;
@@ -37,7 +38,7 @@ public final class ShowProcessListHandler implements GlobalDataChangedEventHandl
@Override
public String getSubscribedKey() {
- return new ShowProcessListTriggerNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath(null, null), false);
}
@Override
@@ -66,6 +67,6 @@ public final class ShowProcessListHandler implements GlobalDataChangedEventHandl
}
private Matcher getShowProcessListTriggerMatcher(final DataChangedEvent event) {
- return Pattern.compile(new ShowProcessListTriggerNodePath().getRootPath() + "/([\\S]+):([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(event.getKey());
+ return Pattern.compile(NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath(null, null), false) + "/([\\S]+):([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(event.getKey());
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/StatisticsChangedHandler.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/StatisticsChangedHandler.java
index e905d10051b..ac682a19ee0 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/StatisticsChangedHandler.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/type/StatisticsChangedHandler.java
@@ -25,8 +25,9 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.GlobalDataChangedEventHandler;
import org.apache.shardingsphere.mode.metadata.manager.statistics.StatisticsManager;
-import org.apache.shardingsphere.mode.node.path.statistics.database.StatisticsDatabaseNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
import org.apache.shardingsphere.mode.node.path.statistics.StatisticsNodePathParser;
+import org.apache.shardingsphere.mode.node.path.statistics.StatisticsDataNodePath;
import java.util.Arrays;
import java.util.Collection;
@@ -39,7 +40,7 @@ public final class StatisticsChangedHandler implements GlobalDataChangedEventHan
@Override
public String getSubscribedKey() {
- return new StatisticsDatabaseNodePath().getRootPath();
+ return NewNodePathGenerator.generatePath(new StatisticsDataNodePath(null, null, null, null), false);
}
@Override
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/database/ClusterDatabaseListenerPersistCoordinator.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/database/ClusterDatabaseListenerPersistCoordinator.java
index 56417a27118..95ee0f5a9c2 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/database/ClusterDatabaseListenerPersistCoordinator.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/database/ClusterDatabaseListenerPersistCoordinator.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.mode.manager.cluster.persist.coordinator.database;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.state.database.DatabaseListenerCoordinatorNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.state.DatabaseListenerCoordinatorNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
/**
@@ -37,7 +37,7 @@ public final class ClusterDatabaseListenerPersistCoordinator {
* @param clusterDatabaseListenerCoordinatorType database changed listener assisted type
*/
public void persist(final String databaseName, final ClusterDatabaseListenerCoordinatorType clusterDatabaseListenerCoordinatorType) {
- repository.persistEphemeral(new NodePathGenerator(new DatabaseListenerCoordinatorNodePath()).getPath(databaseName), clusterDatabaseListenerCoordinatorType.name());
+ repository.persistEphemeral(NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath(databaseName), false), clusterDatabaseListenerCoordinatorType.name());
}
/**
@@ -46,6 +46,6 @@ public final class ClusterDatabaseListenerPersistCoordinator {
* @param databaseName database name
*/
public void delete(final String databaseName) {
- repository.delete(new NodePathGenerator(new DatabaseListenerCoordinatorNodePath()).getPath(databaseName));
+ repository.delete(NewNodePathGenerator.generatePath(new DatabaseListenerCoordinatorNodePath(databaseName), false));
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/process/ClusterProcessPersistCoordinator.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/process/ClusterProcessPersistCoordinator.java
index 402e6c98af8..ecf5f6ebacc 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/process/ClusterProcessPersistCoordinator.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/coordinator/process/ClusterProcessPersistCoordinator.java
@@ -22,8 +22,8 @@ import org.apache.shardingsphere.infra.executor.sql.process.Process;
import org.apache.shardingsphere.infra.executor.sql.process.ProcessRegistry;
import org.apache.shardingsphere.infra.executor.sql.process.yaml.swapper.YamlProcessListSwapper;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.execution.process.ProcessNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.execution.ProcessNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.process.KillProcessTriggerNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.process.ShowProcessListTriggerNodePath;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -49,9 +49,9 @@ public final class ClusterProcessPersistCoordinator {
public void reportLocalProcesses(final String instanceId, final String taskId) {
Collection<Process> processes = ProcessRegistry.getInstance().listAll();
if (!processes.isEmpty()) {
- repository.persist(new NodePathGenerator(new ProcessNodePath(taskId)).getPath(instanceId), YamlEngine.marshal(swapper.swapToYamlConfiguration(processes)));
+ repository.persist(NewNodePathGenerator.generatePath(new ProcessNodePath(taskId, instanceId), false), YamlEngine.marshal(swapper.swapToYamlConfiguration(processes)));
}
- repository.delete(new NodePathGenerator(new ShowProcessListTriggerNodePath()).getPath(String.join(":", instanceId, taskId)));
+ repository.delete(NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath(instanceId, taskId), false));
}
/**
@@ -61,6 +61,6 @@ public final class ClusterProcessPersistCoordinator {
* @param processId process ID
*/
public void cleanProcess(final String instanceId, final String processId) {
- repository.delete(new NodePathGenerator(new KillProcessTriggerNodePath()).getPath(String.join(":", instanceId, processId)));
+ repository.delete(NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath(instanceId, processId), false));
}
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
index b17ea0edace..0eeb60edcd6 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
@@ -24,11 +24,11 @@ import org.apache.shardingsphere.infra.executor.sql.process.yaml.YamlProcessList
import org.apache.shardingsphere.infra.executor.sql.process.yaml.swapper.YamlProcessListSwapper;
import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.execution.process.ProcessNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.execution.ProcessNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.process.KillProcessTriggerNodePath;
import org.apache.shardingsphere.mode.node.path.node.compute.process.ShowProcessListTriggerNodePath;
-import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineTypeNodePath;
+import org.apache.shardingsphere.mode.node.path.node.compute.status.OnlineNodePath;
import org.apache.shardingsphere.mode.persist.service.ProcessPersistService;
import org.apache.shardingsphere.mode.spi.repository.PersistRepository;
@@ -56,7 +56,7 @@ public final class ClusterProcessPersistService implements ProcessPersistService
isCompleted = ProcessOperationLockRegistry.getInstance().waitUntilReleaseReady(taskId, () -> isReady(triggerPaths));
return getShowProcessListData(taskId);
} finally {
- repository.delete(new ProcessNodePath(taskId).getRootPath());
+ repository.delete(NewNodePathGenerator.generatePath(new ProcessNodePath(taskId, null), false));
if (!isCompleted) {
triggerPaths.forEach(repository::delete);
}
@@ -65,15 +65,15 @@ public final class ClusterProcessPersistService implements ProcessPersistService
private Collection<String> getShowProcessListTriggerPaths(final String taskId) {
return Stream.of(InstanceType.values())
- .flatMap(each -> repository.getChildrenKeys(new NodePathGenerator(new OnlineTypeNodePath()).getPath(each.name().toLowerCase())).stream()
- .map(instanceId -> new NodePathGenerator(new ShowProcessListTriggerNodePath()).getPath(String.join(":", instanceId, taskId))))
+ .flatMap(each -> repository.getChildrenKeys(NewNodePathGenerator.generatePath(new OnlineNodePath(each, null), false)).stream()
+ .map(instanceId -> NewNodePathGenerator.generatePath(new ShowProcessListTriggerNodePath(instanceId, taskId), false)))
.collect(Collectors.toList());
}
private Collection<Process> getShowProcessListData(final String taskId) {
YamlProcessList yamlProcessList = new YamlProcessList();
- for (String each : repository.getChildrenKeys(new ProcessNodePath(taskId).getRootPath()).stream()
- .map(each -> repository.query(new NodePathGenerator(new ProcessNodePath(taskId)).getPath(each))).collect(Collectors.toList())) {
+ for (String each : repository.getChildrenKeys(NewNodePathGenerator.generatePath(new ProcessNodePath(taskId, null), false)).stream()
+ .map(each -> repository.query(NewNodePathGenerator.generatePath(new ProcessNodePath(taskId, each), false))).collect(Collectors.toList())) {
yamlProcessList.getProcesses().addAll(YamlEngine.unmarshal(each, YamlProcessList.class).getProcesses());
}
return new YamlProcessListSwapper().swapToObject(yamlProcessList);
@@ -95,8 +95,8 @@ public final class ClusterProcessPersistService implements ProcessPersistService
private Collection<String> getKillProcessTriggerPaths(final String processId) {
return Stream.of(InstanceType.values())
- .flatMap(each -> repository.getChildrenKeys(new NodePathGenerator(new OnlineTypeNodePath()).getPath(each.name().toLowerCase())).stream()
- .map(onlinePath -> new NodePathGenerator(new KillProcessTriggerNodePath()).getPath(String.join(":", onlinePath, processId))))
+ .flatMap(each -> repository.getChildrenKeys(NewNodePathGenerator.generatePath(new OnlineNodePath(each, null), false)).stream()
+ .map(onlinePath -> NewNodePathGenerator.generatePath(new KillProcessTriggerNodePath(onlinePath, processId), false)))
.collect(Collectors.toList());
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/workerid/ReservationPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/workerid/ReservationPersistService.java
index 70066a47758..1f12ac096e9 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/workerid/ReservationPersistService.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/workerid/ReservationPersistService.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.mode.manager.cluster.workerid;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.mode.node.path.NodePathGenerator;
-import org.apache.shardingsphere.mode.node.path.reservation.workerid.WorkerIDReservationNodePath;
+import org.apache.shardingsphere.mode.node.path.NewNodePathGenerator;
+import org.apache.shardingsphere.mode.node.path.reservation.WorkerIDReservationNodePath;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.exception.ClusterRepositoryPersistException;
@@ -43,7 +43,7 @@ public final class ReservationPersistService {
public Optional<Integer> reserveWorkerId(final Integer preselectedWorkerId, final String instanceId) {
try {
return repository.persistExclusiveEphemeral(
- new NodePathGenerator(new WorkerIDReservationNodePath()).getPath(preselectedWorkerId), instanceId) ? Optional.of(preselectedWorkerId) : Optional.empty();
+ NewNodePathGenerator.generatePath(new WorkerIDReservationNodePath(preselectedWorkerId), false), instanceId) ? Optional.of(preselectedWorkerId) : Optional.empty();
} catch (final ClusterRepositoryPersistException ignore) {
return Optional.empty();
}