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/24 09:13:54 UTC
(shardingsphere) branch master updated: Rename DatabaseRuleNode (#34774)
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 30337d4a666 Rename DatabaseRuleNode (#34774)
30337d4a666 is described below
commit 30337d4a6663d81a88beb988980d51d4ccb4f120
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Feb 24 17:13:46 2025 +0800
Rename DatabaseRuleNode (#34774)
* Refactor NamedDatabaseRuleItemNodePath and UniqueDatabaseRuleItemNodePath
* Rename DatabaseRuleNode
---
.../nodepath/BroadcastRuleNodePathProvider.java | 6 +--
.../BroadcastRuleNodePathProviderTest.java | 4 +-
.../nodepath/EncryptRuleNodePathProvider.java | 6 +--
.../nodepath/EncryptRuleNodePathProviderTest.java | 4 +-
.../nodepath/MaskRuleNodePathProvider.java | 6 +--
.../nodepath/MaskRuleNodePathProviderTest.java | 4 +-
.../ReadwriteSplittingRuleNodePathProvider.java | 6 +--
...ReadwriteSplittingRuleNodePathProviderTest.java | 4 +-
.../nodepath/ShadowRuleNodePathProvider.java | 8 ++--
.../nodepath/ShadowRuleNodePathProviderTest.java | 4 +-
.../nodepath/ShardingRuleNodePathProvider.java | 6 +--
.../nodepath/ShardingRuleNodePathProviderTest.java | 4 +-
.../nodepath/SingleRuleNodePathProvider.java | 6 +--
.../nodepath/SingleRuleNodePathProviderTest.java | 4 +-
.../executor/RuleItemChangedBuildExecutor.java | 6 +--
.../type/RuleItemAlteredBuildExecutor.java | 12 ++---
.../type/RuleItemDroppedBuildExecutor.java | 12 ++---
...baseRuleNodePath.java => DatabaseRuleNode.java} | 6 +--
.../item/NamedDatabaseRuleItemNodePath.java | 12 +----
.../item/UniqueDatabaseRuleItemNodePath.java | 11 +----
.../node/spi/DatabaseRuleNodePathProvider.java | 4 +-
.../tuple/YamlRepositoryTupleSwapperEngine.java | 53 +++++++++++-----------
.../type/config/database/RuleNodePathTest.java | 16 +++----
.../item/NamedDatabaseRuleItemNodePathTest.java | 5 --
.../item/UniqueDatabaseRuleItemNodePathTest.java | 2 +-
...NodePathTest.java => DatabaseRuleNodeTest.java} | 2 +-
.../fixture/node/RuleNodePathProviderFixture.java | 6 +--
.../rule/RuleConfigurationChangedHandlerTest.java | 4 +-
28 files changed, 99 insertions(+), 124 deletions(-)
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProvider.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProvider.java
index f9c3bac205a..66b32543964 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProvider.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProvider.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.broadcast.metadata.nodepath;
import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import java.util.Collections;
@@ -33,10 +33,10 @@ public final class BroadcastRuleNodePathProvider implements DatabaseRuleNodePath
public static final String TABLES = "tables";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Collections.emptyList(), Collections.singleton(TABLES));
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Collections.emptyList(), Collections.singleton(TABLES));
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProviderTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProviderTest.java
index d333550f097..14bb695b91e 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProviderTest.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodePathProviderTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.broadcast.metadata.nodepath;
import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class BroadcastRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertTrue(actual.getNamedItems().isEmpty());
assertThat(actual.getUniqueItems().size(), is(1));
assertTrue(actual.getUniqueItems().containsKey(BroadcastRuleNodePathProvider.TABLES));
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProvider.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProvider.java
index 1bdfe7a202f..7a86d9f3967 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProvider.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProvider.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.encrypt.metadata.nodepath;
import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import java.util.Arrays;
@@ -36,10 +36,10 @@ public final class EncryptRuleNodePathProvider implements DatabaseRuleNodePathPr
public static final String ENCRYPTORS = "encryptors";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(TABLES, ENCRYPTORS), Collections.emptyList());
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(TABLES, ENCRYPTORS), Collections.emptyList());
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProviderTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProviderTest.java
index df4dca76a6b..7f34e92f196 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProviderTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodePathProviderTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.encrypt.metadata.nodepath;
import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class EncryptRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertThat(actual.getNamedItems().size(), is(2));
assertTrue(actual.getNamedItems().containsKey(EncryptRuleNodePathProvider.ENCRYPTORS));
assertTrue(actual.getNamedItems().containsKey(EncryptRuleNodePathProvider.TABLES));
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProvider.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProvider.java
index 24f56e1b84e..28cbd944a56 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProvider.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProvider.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.metadata.nodepath;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import java.util.Arrays;
@@ -36,10 +36,10 @@ public final class MaskRuleNodePathProvider implements DatabaseRuleNodePathProvi
public static final String MASK_ALGORITHMS = "mask_algorithms";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(TABLES, MASK_ALGORITHMS), Collections.emptyList());
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(TABLES, MASK_ALGORITHMS), Collections.emptyList());
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProviderTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProviderTest.java
index cb0fd9eb44a..ed671f911ea 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProviderTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodePathProviderTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.metadata.nodepath;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class MaskRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertThat(actual.getNamedItems().size(), is(2));
assertTrue(actual.getNamedItems().containsKey(MaskRuleNodePathProvider.MASK_ALGORITHMS));
assertTrue(actual.getNamedItems().containsKey(MaskRuleNodePathProvider.TABLES));
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProvider.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProvider.java
index d95ea1643ea..84150179e90 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProvider.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProvider.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.metadata.nodepath;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
@@ -36,10 +36,10 @@ public final class ReadwriteSplittingRuleNodePathProvider implements DatabaseRul
public static final String LOAD_BALANCERS = "load_balancers";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(DATA_SOURCE_GROUPS, LOAD_BALANCERS), Collections.emptyList());
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(DATA_SOURCE_GROUPS, LOAD_BALANCERS), Collections.emptyList());
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProviderTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProviderTest.java
index 8b44a0946cc..7ba00cf25ac 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProviderTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodePathProviderTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.metadata.nodepath;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class ReadwriteSplittingRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertThat(actual.getNamedItems().size(), is(2));
assertTrue(actual.getNamedItems().containsKey(ReadwriteSplittingRuleNodePathProvider.DATA_SOURCE_GROUPS));
assertTrue(actual.getNamedItems().containsKey(ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS));
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProvider.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProvider.java
index 913bf5e594a..d76a8312bba 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProvider.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProvider.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.metadata.nodepath;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
@@ -40,11 +40,11 @@ public final class ShadowRuleNodePathProvider implements DatabaseRuleNodePathPro
public static final String DEFAULT_SHADOW_ALGORITHM_NAME = "default_shadow_algorithm_name";
- private static final DatabaseRuleNodePath INSTANCE =
- new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(DATA_SOURCES, TABLES, SHADOW_ALGORITHMS), Collections.singleton(DEFAULT_SHADOW_ALGORITHM_NAME));
+ private static final DatabaseRuleNode INSTANCE =
+ new DatabaseRuleNode(RULE_TYPE, Arrays.asList(DATA_SOURCES, TABLES, SHADOW_ALGORITHMS), Collections.singleton(DEFAULT_SHADOW_ALGORITHM_NAME));
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProviderTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProviderTest.java
index 2c543401084..0a02939be76 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProviderTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodePathProviderTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.metadata.nodepath;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class ShadowRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertThat(actual.getNamedItems().size(), is(3));
assertTrue(actual.getNamedItems().containsKey(ShadowRuleNodePathProvider.SHADOW_ALGORITHMS));
assertTrue(actual.getNamedItems().containsKey(ShadowRuleNodePathProvider.TABLES));
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProvider.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProvider.java
index 5d07155947c..5ed43095d9e 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProvider.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProvider.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.metadata.nodepath;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -55,12 +55,12 @@ public final class ShardingRuleNodePathProvider implements DatabaseRuleNodePathP
public static final String SHARDING_CACHE = "sharding_cache";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE,
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE,
Arrays.asList(TABLES, AUTO_TABLES, BINDING_TABLES, SHARDING_ALGORITHMS, KEY_GENERATORS, AUDITORS),
Arrays.asList(DEFAULT_DATABASE_STRATEGY, DEFAULT_TABLE_STRATEGY, DEFAULT_KEY_GENERATE_STRATEGY, DEFAULT_AUDIT_STRATEGY, DEFAULT_SHARDING_COLUMN, SHARDING_CACHE));
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProviderTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProviderTest.java
index 5dfc1412bc9..cd1c89902ed 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProviderTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodePathProviderTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.metadata.nodepath;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.hamcrest.collection.IsIterableContainingInAnyOrder;
@@ -36,7 +36,7 @@ class ShardingRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertThat(actual.getNamedItems().size(), is(6));
List<String> namedRuleItems = Arrays.asList(ShardingRuleNodePathProvider.TABLES, ShardingRuleNodePathProvider.AUTO_TABLES, ShardingRuleNodePathProvider.BINDING_TABLES,
ShardingRuleNodePathProvider.SHARDING_ALGORITHMS, ShardingRuleNodePathProvider.KEY_GENERATORS, ShardingRuleNodePathProvider.AUDITORS);
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProvider.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProvider.java
index 68ac5885dfe..753421c894a 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProvider.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProvider.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.single.metadata.nodepath;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
@@ -36,10 +36,10 @@ public final class SingleRuleNodePathProvider implements DatabaseRuleNodePathPro
public static final String DEFAULT_DATA_SOURCE = "default_data_source";
- private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Collections.emptyList(), Arrays.asList(TABLES, DEFAULT_DATA_SOURCE));
+ private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Collections.emptyList(), Arrays.asList(TABLES, DEFAULT_DATA_SOURCE));
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
return INSTANCE;
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProviderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProviderTest.java
index 40e8788d323..9d32f99b077 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProviderTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodePathProviderTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.single.metadata.nodepath;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ class SingleRuleNodePathProviderTest {
@Test
void assertGetDatabaseRuleNodePath() {
- DatabaseRuleNodePath actual = pathProvider.getDatabaseRuleNodePath();
+ DatabaseRuleNode actual = pathProvider.getDatabaseRuleNodePath();
assertTrue(actual.getNamedItems().isEmpty());
assertThat(actual.getUniqueItems().size(), is(2));
assertTrue(actual.getUniqueItems().containsKey(SingleRuleNodePathProvider.TABLES));
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/RuleItemChangedBuildExecutor.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/RuleItemChangedBuildExecutor.java
index 10bfcb22da1..725c596ca2e 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/RuleItemChangedBuildExecutor.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/RuleItemChangedBuildExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mode.metadata.changed.executor;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.spi.rule.item.RuleChangedItem;
import java.util.Optional;
@@ -32,11 +32,11 @@ public interface RuleItemChangedBuildExecutor<T extends RuleChangedItem> {
/**
* Build rule item.
*
- * @param databaseRuleNodePath rule node path
+ * @param databaseRuleNode rule node path
* @param databaseName database name
* @param path path
* @param activeVersion active version
* @return built rule item
*/
- Optional<T> build(DatabaseRuleNodePath databaseRuleNodePath, String databaseName, String path, Integer activeVersion);
+ Optional<T> build(DatabaseRuleNode databaseRuleNode, String databaseName, String path, Integer activeVersion);
}
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemAlteredBuildExecutor.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemAlteredBuildExecutor.java
index 9f528921979..849aabba303 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemAlteredBuildExecutor.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemAlteredBuildExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mode.metadata.changed.executor.type;
import org.apache.shardingsphere.mode.metadata.changed.executor.RuleItemChangedBuildExecutor;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.path.type.config.database.item.NamedDatabaseRuleItemNodePath;
import org.apache.shardingsphere.mode.node.path.type.config.database.item.UniqueDatabaseRuleItemNodePath;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
@@ -34,16 +34,16 @@ import java.util.Optional;
public final class RuleItemAlteredBuildExecutor implements RuleItemChangedBuildExecutor<AlterRuleItem> {
@Override
- public Optional<AlterRuleItem> build(final DatabaseRuleNodePath databaseRuleNodePath, final String databaseName, final String path, final Integer activeVersion) {
- for (Entry<String, NamedDatabaseRuleItemNodePath> entry : databaseRuleNodePath.getNamedItems().entrySet()) {
+ public Optional<AlterRuleItem> build(final DatabaseRuleNode databaseRuleNode, final String databaseName, final String path, final Integer activeVersion) {
+ for (Entry<String, NamedDatabaseRuleItemNodePath> entry : databaseRuleNode.getNamedItems().entrySet()) {
Optional<String> itemName = entry.getValue().getVersionNodePathParser().findIdentifierByActiveVersionPath(path, 2);
if (itemName.isPresent()) {
- return Optional.of(new AlterNamedRuleItem(databaseName, itemName.get(), path, activeVersion, databaseRuleNodePath.getRuleType() + "." + entry.getKey()));
+ return Optional.of(new AlterNamedRuleItem(databaseName, itemName.get(), path, activeVersion, databaseRuleNode.getRuleType() + "." + entry.getKey()));
}
}
- for (Entry<String, UniqueDatabaseRuleItemNodePath> entry : databaseRuleNodePath.getUniqueItems().entrySet()) {
+ for (Entry<String, UniqueDatabaseRuleItemNodePath> entry : databaseRuleNode.getUniqueItems().entrySet()) {
if (entry.getValue().getVersionNodePathParser().isActiveVersionPath(path)) {
- return Optional.of(new AlterUniqueRuleItem(databaseName, path, activeVersion, databaseRuleNodePath.getRuleType() + "." + entry.getKey()));
+ return Optional.of(new AlterUniqueRuleItem(databaseName, path, activeVersion, databaseRuleNode.getRuleType() + "." + entry.getKey()));
}
}
return Optional.empty();
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemDroppedBuildExecutor.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemDroppedBuildExecutor.java
index 26f176efc43..dc00be1e668 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemDroppedBuildExecutor.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/executor/type/RuleItemDroppedBuildExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mode.metadata.changed.executor.type;
import org.apache.shardingsphere.mode.metadata.changed.executor.RuleItemChangedBuildExecutor;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.path.type.config.database.item.NamedDatabaseRuleItemNodePath;
import org.apache.shardingsphere.mode.node.path.type.config.database.item.UniqueDatabaseRuleItemNodePath;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
@@ -34,16 +34,16 @@ import java.util.Optional;
public final class RuleItemDroppedBuildExecutor implements RuleItemChangedBuildExecutor<DropRuleItem> {
@Override
- public Optional<DropRuleItem> build(final DatabaseRuleNodePath databaseRuleNodePath, final String databaseName, final String path, final Integer activeVersion) {
- for (Entry<String, NamedDatabaseRuleItemNodePath> entry : databaseRuleNodePath.getNamedItems().entrySet()) {
+ public Optional<DropRuleItem> build(final DatabaseRuleNode databaseRuleNode, final String databaseName, final String path, final Integer activeVersion) {
+ for (Entry<String, NamedDatabaseRuleItemNodePath> entry : databaseRuleNode.getNamedItems().entrySet()) {
Optional<String> itemName = entry.getValue().findNameByItemPath(path);
if (itemName.isPresent()) {
- return Optional.of(new DropNamedRuleItem(databaseName, itemName.get(), databaseRuleNodePath.getRuleType() + "." + entry.getKey()));
+ return Optional.of(new DropNamedRuleItem(databaseName, itemName.get(), databaseRuleNode.getRuleType() + "." + entry.getKey()));
}
}
- for (Entry<String, UniqueDatabaseRuleItemNodePath> entry : databaseRuleNodePath.getUniqueItems().entrySet()) {
+ for (Entry<String, UniqueDatabaseRuleItemNodePath> entry : databaseRuleNode.getUniqueItems().entrySet()) {
if (entry.getValue().getVersionNodePathParser().isActiveVersionPath(path)) {
- return Optional.of(new DropUniqueRuleItem(databaseName, databaseRuleNodePath.getRuleType() + "." + entry.getKey()));
+ return Optional.of(new DropUniqueRuleItem(databaseName, databaseRuleNode.getRuleType() + "." + entry.getKey()));
}
}
return Optional.empty();
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNode.java
similarity index 92%
rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNodePath.java
rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNode.java
index e4f5569b1e5..5c167d85ef6 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/DatabaseRuleNode.java
@@ -26,10 +26,10 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
- * Database rule node path.
+ * Database rule node.
*/
@Getter
-public final class DatabaseRuleNodePath {
+public final class DatabaseRuleNode {
private final String ruleType;
@@ -37,7 +37,7 @@ public final class DatabaseRuleNodePath {
private final Map<String, UniqueDatabaseRuleItemNodePath> uniqueItems;
- public DatabaseRuleNodePath(final String ruleType, final Collection<String> namedRuleItemNodePathTypes, final Collection<String> uniqueRuleItemNodePathTypes) {
+ public DatabaseRuleNode(final String ruleType, final Collection<String> namedRuleItemNodePathTypes, final Collection<String> uniqueRuleItemNodePathTypes) {
this.ruleType = ruleType;
namedItems = getNamedRuleItemNodePathMap(namedRuleItemNodePathTypes);
uniqueItems = getUniqueRuleItemNodePathMap(uniqueRuleItemNodePathTypes);
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePath.java
index 1865e947aad..b4a349e7aa6 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePath.java
@@ -30,13 +30,13 @@ import java.util.Optional;
/**
* Named database rule item node path.
*/
+@Getter
public final class NamedDatabaseRuleItemNodePath {
private final String type;
private final DatabaseRuleNodePath databaseRuleNodePath;
- @Getter
private final VersionNodePathParser versionNodePathParser;
public NamedDatabaseRuleItemNodePath(final String ruleType, final String type) {
@@ -45,16 +45,6 @@ public final class NamedDatabaseRuleItemNodePath {
versionNodePathParser = NodePathSearcher.getVersion(databaseRuleNodePath);
}
- /**
- * Get rule item path.
- *
- * @param itemName item name
- * @return rule item path
- */
- public String getPath(final String itemName) {
- return String.join("/", type, itemName);
- }
-
/**
* Find rule item name by item path.
*
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePath.java
index 28beb58f547..26fab1f43d5 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePath.java
@@ -27,24 +27,15 @@ import org.apache.shardingsphere.mode.node.path.type.version.VersionNodePathPars
/**
* Unique database rule item node path.
*/
+@Getter
public final class UniqueDatabaseRuleItemNodePath {
private final String type;
- @Getter
private final VersionNodePathParser versionNodePathParser;
public UniqueDatabaseRuleItemNodePath(final String ruleType, final String type) {
this.type = type;
versionNodePathParser = NodePathSearcher.getVersion(new DatabaseRuleNodePath(NodePathPattern.IDENTIFIER, ruleType, new DatabaseRuleItem(type)));
}
-
- /**
- * Get path.
- *
- * @return path
- */
- public String getPath() {
- return String.join("/", type);
- }
}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java
index 09b62e01d2d..f2ea2a63e11 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mode.node.spi;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
/**
* Database rule node path provider.
@@ -33,7 +33,7 @@ public interface DatabaseRuleNodePathProvider extends TypedSPI {
*
* @return got database rule node path
*/
- DatabaseRuleNodePath getDatabaseRuleNodePath();
+ DatabaseRuleNode getDatabaseRuleNodePath();
@Override
Class<? extends RuleConfiguration> getType();
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/tuple/YamlRepositoryTupleSwapperEngine.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/tuple/YamlRepositoryTupleSwapperEngine.java
index fc001db99db..b13bf123809 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/tuple/YamlRepositoryTupleSwapperEngine.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/tuple/YamlRepositoryTupleSwapperEngine.java
@@ -30,8 +30,10 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearcher;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.path.type.config.global.GlobalRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleItem;
+import org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleNodePath;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.mode.node.tuple.annotation.RepositoryTupleEntity;
import org.apache.shardingsphere.mode.node.tuple.annotation.RepositoryTupleField;
@@ -71,11 +73,11 @@ public final class YamlRepositoryTupleSwapperEngine {
return Collections.singleton(new RepositoryTuple(tupleEntity.value(), YamlEngine.marshal(yamlRuleConfig)));
}
Collection<RepositoryTuple> result = new LinkedList<>();
- DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
+ DatabaseRuleNode databaseRuleNode = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
for (Field each : getFields(yamlRuleConfig.getClass())) {
boolean isAccessible = each.isAccessible();
each.setAccessible(true);
- result.addAll(swapToRepositoryTuples(yamlRuleConfig, databaseRuleNodePath, each));
+ result.addAll(swapToRepositoryTuples(yamlRuleConfig, databaseRuleNode, each));
each.setAccessible(isAccessible);
}
return result;
@@ -83,7 +85,7 @@ public final class YamlRepositoryTupleSwapperEngine {
@SneakyThrows(ReflectiveOperationException.class)
@SuppressWarnings("rawtypes")
- private Collection<RepositoryTuple> swapToRepositoryTuples(final YamlRuleConfiguration yamlRuleConfig, final DatabaseRuleNodePath databaseRuleNodePath, final Field field) {
+ private Collection<RepositoryTuple> swapToRepositoryTuples(final YamlRuleConfiguration yamlRuleConfig, final DatabaseRuleNode databaseRuleNode, final Field field) {
Object fieldValue = field.get(yamlRuleConfig);
if (null == fieldValue) {
return Collections.emptyList();
@@ -94,34 +96,35 @@ public final class YamlRepositoryTupleSwapperEngine {
Collection<RepositoryTuple> result = new LinkedList<>();
for (Object value : (Collection) fieldValue) {
String tupleKeyName = tupleKeyListNameGenerator.value().getConstructor().newInstance().generate(value);
- result.add(new RepositoryTuple(databaseRuleNodePath.getNamedItem(tupleName).getPath(tupleKeyName), value.toString()));
+ result.add(new RepositoryTuple(new DatabaseRuleItem(databaseRuleNode.getNamedItem(tupleName).getType(), tupleKeyName).toString(), value.toString()));
}
return result;
}
if (fieldValue instanceof Map) {
Collection<RepositoryTuple> result = new LinkedList<>();
for (Object entry : ((Map) fieldValue).entrySet()) {
- result.add(new RepositoryTuple(databaseRuleNodePath.getNamedItem(tupleName).getPath(((Entry) entry).getKey().toString()), YamlEngine.marshal(((Entry) entry).getValue())));
+ result.add(new RepositoryTuple(
+ new DatabaseRuleItem(databaseRuleNode.getNamedItem(tupleName).getType(), ((Entry) entry).getKey().toString()).toString(), YamlEngine.marshal(((Entry) entry).getValue())));
}
return result;
}
if (fieldValue instanceof Collection) {
return ((Collection) fieldValue).isEmpty()
? Collections.emptyList()
- : Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue)));
+ : Collections.singleton(new RepositoryTuple(databaseRuleNode.getUniqueItem(tupleName).getType(), YamlEngine.marshal(fieldValue)));
}
if (fieldValue instanceof String) {
return ((String) fieldValue).isEmpty()
? Collections.emptyList()
- : Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString()));
+ : Collections.singleton(new RepositoryTuple(databaseRuleNode.getUniqueItem(tupleName).getType(), fieldValue.toString()));
}
if (fieldValue instanceof Boolean || fieldValue instanceof Integer || fieldValue instanceof Long) {
- return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString()));
+ return Collections.singleton(new RepositoryTuple(databaseRuleNode.getUniqueItem(tupleName).getType(), fieldValue.toString()));
}
if (fieldValue instanceof Enum) {
- return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), ((Enum) fieldValue).name()));
+ return Collections.singleton(new RepositoryTuple(databaseRuleNode.getUniqueItem(tupleName).getType(), ((Enum) fieldValue).name()));
}
- return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue)));
+ return Collections.singleton(new RepositoryTuple(databaseRuleNode.getUniqueItem(tupleName).getType(), YamlEngine.marshal(fieldValue)));
}
private Collection<Field> getFields(final Class<? extends YamlRuleConfiguration> yamlRuleConfigurationClass) {
@@ -163,12 +166,10 @@ public final class YamlRepositoryTupleSwapperEngine {
return Optional.empty();
}
YamlRuleConfiguration yamlRuleConfig = toBeSwappedType.getConstructor().newInstance();
- DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
+ DatabaseRuleNode databaseRuleNode = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
for (RepositoryTuple each : repositoryTuples.stream()
- .filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(
- databaseRuleNodePath.getRuleType())))
- .collect(Collectors.toList())) {
- if (databaseRuleNodePath.getUniqueItem(tupleEntity.value()).getVersionNodePathParser().isVersionPath(each.getKey())) {
+ .filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(databaseRuleNode.getRuleType()))).collect(Collectors.toList())) {
+ if (databaseRuleNode.getUniqueItem(tupleEntity.value()).getVersionNodePathParser().isVersionPath(each.getKey())) {
return Optional.of(YamlEngine.unmarshal(each.getValue(), toBeSwappedType));
}
}
@@ -179,50 +180,48 @@ public final class YamlRepositoryTupleSwapperEngine {
private Optional<YamlRuleConfiguration> swapToYamlRuleConfiguration(final Collection<RepositoryTuple> repositoryTuples,
final Class<? extends YamlRuleConfiguration> toBeSwappedType, final Collection<Field> fields) {
YamlRuleConfiguration yamlRuleConfig = toBeSwappedType.getConstructor().newInstance();
- DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
+ DatabaseRuleNode databaseRuleNode = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath();
List<RepositoryTuple> validTuples = repositoryTuples.stream()
- .filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(
- databaseRuleNodePath.getRuleType())))
- .collect(Collectors.toList());
+ .filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(databaseRuleNode.getRuleType()))).collect(Collectors.toList());
if (validTuples.isEmpty()) {
return Optional.empty();
}
for (RepositoryTuple each : validTuples) {
if (!Strings.isNullOrEmpty(each.getValue())) {
- setFieldValue(yamlRuleConfig, fields, databaseRuleNodePath, each);
+ setFieldValue(yamlRuleConfig, fields, databaseRuleNode, each);
}
}
return Optional.of(yamlRuleConfig);
}
@SneakyThrows(ReflectiveOperationException.class)
- private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Collection<Field> fields, final DatabaseRuleNodePath databaseRuleNodePath, final RepositoryTuple repositoryTuple) {
+ private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Collection<Field> fields, final DatabaseRuleNode databaseRuleNode, final RepositoryTuple repositoryTuple) {
for (Field each : fields) {
boolean isAccessible = each.isAccessible();
each.setAccessible(true);
- setFieldValue(yamlRuleConfig, each, databaseRuleNodePath, repositoryTuple);
+ setFieldValue(yamlRuleConfig, each, databaseRuleNode, repositoryTuple);
each.setAccessible(isAccessible);
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Field field, final DatabaseRuleNodePath databaseRuleNodePath,
+ private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Field field, final DatabaseRuleNode databaseRuleNode,
final RepositoryTuple repositoryTuple) throws IllegalAccessException {
Object fieldValue = field.get(yamlRuleConfig);
String tupleName = getTupleName(field);
RepositoryTupleKeyListNameGenerator tupleKeyListNameGenerator = field.getAnnotation(RepositoryTupleKeyListNameGenerator.class);
if (null != tupleKeyListNameGenerator && fieldValue instanceof Collection) {
- databaseRuleNodePath.getNamedItem(tupleName).getVersionNodePathParser()
+ databaseRuleNode.getNamedItem(tupleName).getVersionNodePathParser()
.findIdentifierByVersionsPath(repositoryTuple.getKey(), 2).ifPresent(optional -> ((Collection) fieldValue).add(repositoryTuple.getValue()));
return;
}
if (fieldValue instanceof Map) {
Class<?> valueClass = (Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1];
- databaseRuleNodePath.getNamedItem(tupleName).getVersionNodePathParser().findIdentifierByVersionsPath(repositoryTuple.getKey(), 2)
+ databaseRuleNode.getNamedItem(tupleName).getVersionNodePathParser().findIdentifierByVersionsPath(repositoryTuple.getKey(), 2)
.ifPresent(optional -> ((Map) fieldValue).put(optional, YamlEngine.unmarshal(repositoryTuple.getValue(), valueClass)));
return;
}
- if (!databaseRuleNodePath.getUniqueItem(tupleName).getVersionNodePathParser().isVersionPath(repositoryTuple.getKey())) {
+ if (!databaseRuleNode.getUniqueItem(tupleName).getVersionNodePathParser().isVersionPath(repositoryTuple.getKey())) {
return;
}
if (fieldValue instanceof Collection) {
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/RuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/RuleNodePathTest.java
index cbb408b45c5..c17283150f7 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/RuleNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/RuleNodePathTest.java
@@ -31,26 +31,26 @@ import static org.hamcrest.MatcherAssert.assertThat;
class RuleNodePathTest {
- private DatabaseRuleNodePath databaseRuleNodePath;
+ private DatabaseRuleNode databaseRuleNode;
@BeforeEach
void setup() {
List<String> namedRuleItemNodePathTypes = Collections.singletonList("tables");
List<String> uniqueRuleItemNodePathTypes = Arrays.asList("tables", "tables/type");
- databaseRuleNodePath = new DatabaseRuleNodePath("foo", namedRuleItemNodePathTypes, uniqueRuleItemNodePathTypes);
+ databaseRuleNode = new DatabaseRuleNode("foo", namedRuleItemNodePathTypes, uniqueRuleItemNodePathTypes);
}
@Test
void assertFindNameByVersion() {
- NamedDatabaseRuleItemNodePath namedRulePath = databaseRuleNodePath.getNamedItem("tables");
- assertThat(namedRulePath.getPath("foo_tbl"), is("tables/foo_tbl"));
+ NamedDatabaseRuleItemNodePath namedRulePath = databaseRuleNode.getNamedItem("tables");
+ assertThat(namedRulePath.getType(), is("tables"));
}
@Test
void assertGetUniqueItem() {
- UniqueDatabaseRuleItemNodePath uniqueRulePath = databaseRuleNodePath.getUniqueItem("tables");
- assertThat(uniqueRulePath.getPath(), is("tables"));
- UniqueDatabaseRuleItemNodePath uniqueRulePathWithType = databaseRuleNodePath.getUniqueItem("tables/type");
- assertThat(uniqueRulePathWithType.getPath(), is("tables/type"));
+ UniqueDatabaseRuleItemNodePath uniqueRulePath = databaseRuleNode.getUniqueItem("tables");
+ assertThat(uniqueRulePath.getType(), is("tables"));
+ UniqueDatabaseRuleItemNodePath uniqueRulePathWithType = databaseRuleNode.getUniqueItem("tables/type");
+ assertThat(uniqueRulePathWithType.getType(), is("tables/type"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePathTest.java
index 57e9b4920c9..077b54d721a 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/NamedDatabaseRuleItemNodePathTest.java
@@ -30,11 +30,6 @@ class NamedDatabaseRuleItemNodePathTest {
private final NamedDatabaseRuleItemNodePath nodePath = new NamedDatabaseRuleItemNodePath("foo", "tables");
- @Test
- void assertGetPath() {
- assertThat(nodePath.getPath("foo_tbl"), is("tables/foo_tbl"));
- }
-
@Test
void assertFindNameByItemPath() {
Optional<String> actual = nodePath.findNameByItemPath("/metadata/foo_db/rules/foo/tables/foo_tbl");
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePathTest.java
index 17c28bbc608..62827ae9840 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/config/database/item/UniqueDatabaseRuleItemNodePathTest.java
@@ -27,6 +27,6 @@ class UniqueDatabaseRuleItemNodePathTest {
@Test
void assertPath() {
UniqueDatabaseRuleItemNodePath uniqueDatabaseRuleItemNodePath = new UniqueDatabaseRuleItemNodePath("foo", "test_path");
- assertThat(uniqueDatabaseRuleItemNodePath.getPath(), is("test_path"));
+ assertThat(uniqueDatabaseRuleItemNodePath.getType(), is("test_path"));
}
}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodeTest.java
similarity index 98%
rename from mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePathTest.java
rename to mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodeTest.java
index 6f2b85ce316..20de51716b3 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodeTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class DatabaseRuleNodePathTest {
+class DatabaseRuleNodeTest {
@Test
void assertToPath() {
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/tuple/fixture/node/RuleNodePathProviderFixture.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/tuple/fixture/node/RuleNodePathProviderFixture.java
index f2edf7f37e9..054d60399f2 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/tuple/fixture/node/RuleNodePathProviderFixture.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/tuple/fixture/node/RuleNodePathProviderFixture.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mode.node.tuple.fixture.node;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import java.util.Arrays;
@@ -26,8 +26,8 @@ import java.util.Arrays;
public final class RuleNodePathProviderFixture implements DatabaseRuleNodePathProvider {
@Override
- public DatabaseRuleNodePath getDatabaseRuleNodePath() {
- return new DatabaseRuleNodePath("node", Arrays.asList("map_value", "gens"),
+ public DatabaseRuleNode getDatabaseRuleNodePath() {
+ return new DatabaseRuleNode("node", Arrays.asList("map_value", "gens"),
Arrays.asList("collection_value", "string_value", "boolean_value", "integer_value", "long_value", "enum_value", "gen", "leaf"));
}
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandlerTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandlerTest.java
index 95353776252..0b49e25fc8e 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandlerTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/RuleConfigurationChangedHandlerTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
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.node.path.type.config.database.DatabaseRuleNodePath;
+import org.apache.shardingsphere.mode.node.path.type.config.database.DatabaseRuleNode;
import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterUniqueRuleItem;
@@ -58,7 +58,7 @@ class RuleConfigurationChangedHandlerTest {
void setUp() {
handler = new RuleConfigurationChangedHandler(contextManager);
DatabaseRuleNodePathProvider databaseRuleNodePathProvider = mock(DatabaseRuleNodePathProvider.class, RETURNS_DEEP_STUBS);
- when(databaseRuleNodePathProvider.getDatabaseRuleNodePath()).thenReturn(new DatabaseRuleNodePath("foo_rule", Collections.singleton("named"), Collections.singleton("unique")));
+ when(databaseRuleNodePathProvider.getDatabaseRuleNodePath()).thenReturn(new DatabaseRuleNode("foo_rule", Collections.singleton("named"), Collections.singleton("unique")));
when(ShardingSphereServiceLoader.getServiceInstances(DatabaseRuleNodePathProvider.class)).thenReturn(Collections.singleton(databaseRuleNodePathProvider));
}