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 8d6081eca6e Rename DatabaseRuleNodePath (#34656) 8d6081eca6e is described below commit 8d6081eca6ee90c8713ee9f3afc06cdc44135d5a Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Thu Feb 13 13:38:17 2025 +0800 Rename DatabaseRuleNodePath (#34656) * Rename DatabaseRuleNodePath * Rename DatabaseRuleNodePath --- .../nodepath/BroadcastRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../BroadcastRuleNodePathProviderTest.java | 10 ++--- .../nodepath/EncryptRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../nodepath/EncryptRuleNodePathProviderTest.java | 10 ++--- .../nodepath/MaskRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../nodepath/MaskRuleNodePathProviderTest.java | 10 ++--- .../ReadwriteSplittingRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 ...ReadwriteSplittingRuleNodePathProviderTest.java | 10 ++--- .../nodepath/ShadowRuleNodePathProvider.java | 11 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../nodepath/ShadowRuleNodePathProviderTest.java | 10 ++--- .../nodepath/ShardingRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../nodepath/ShardingRuleNodePathProviderTest.java | 10 ++--- .../nodepath/SingleRuleNodePathProvider.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../nodepath/SingleRuleNodePathProviderTest.java | 10 ++--- .../metadata/changed/RuleItemChangedBuilder.java | 8 ++-- .../executor/RuleItemChangedBuildExecutor.java | 6 +-- .../type/RuleItemAlteredBuildExecutor.java | 12 ++--- .../type/RuleItemDroppedBuildExecutor.java | 12 ++--- ...RuleNodePath.java => DatabaseRuleNodePath.java} | 6 +-- ...ider.java => DatabaseRuleNodePathProvider.java} | 12 ++--- .../tuple/YamlRepositoryTupleSwapperEngine.java | 51 ++++++++++++---------- .../path/config/database/RuleNodePathTest.java | 10 ++--- .../fixture/node/RuleNodePathProviderFixture.java | 10 ++--- ...ere.mode.node.spi.DatabaseRuleNodePathProvider} | 0 .../rule/RuleConfigurationChangedHandlerTest.java | 10 ++--- 32 files changed, 141 insertions(+), 137 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 afa0f96cdf1..2b0cb0f4ab2 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,24 +19,24 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import java.util.Collections; /** * Broadcast rule node path provider. */ -public final class BroadcastRuleNodePathProvider implements RuleNodePathProvider { +public final class BroadcastRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "broadcast"; public static final String TABLES = "tables"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Collections.emptyList(), Collections.singleton(TABLES)); + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Collections.emptyList(), Collections.singleton(TABLES)); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 c5a2556612c..c041d990bfb 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,8 +19,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class BroadcastRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, BroadcastRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, BroadcastRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 a32c4e95021..fbfe514768c 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,8 +19,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import java.util.Arrays; import java.util.Collections; @@ -28,7 +28,7 @@ import java.util.Collections; /** * Encrypt rule node path provider. */ -public final class EncryptRuleNodePathProvider implements RuleNodePathProvider { +public final class EncryptRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "encrypt"; @@ -36,10 +36,10 @@ public final class EncryptRuleNodePathProvider implements RuleNodePathProvider { public static final String ENCRYPTORS = "encryptors"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Arrays.asList(TABLES, ENCRYPTORS), Collections.emptyList()); + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(TABLES, ENCRYPTORS), Collections.emptyList()); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 22a7d89c7bc..c6225f138a6 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,8 +19,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class EncryptRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, EncryptRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, EncryptRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 34c533d7135..1e1efb6f217 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,8 +19,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import java.util.Arrays; import java.util.Collections; @@ -28,7 +28,7 @@ import java.util.Collections; /** * Mask rule node path provider. */ -public final class MaskRuleNodePathProvider implements RuleNodePathProvider { +public final class MaskRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "mask"; @@ -36,10 +36,10 @@ public final class MaskRuleNodePathProvider implements RuleNodePathProvider { public static final String MASK_ALGORITHMS = "mask_algorithms"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Arrays.asList(TABLES, MASK_ALGORITHMS), Collections.emptyList()); + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(TABLES, MASK_ALGORITHMS), Collections.emptyList()); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 933ff3baf8e..1c150fd1267 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,8 +19,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class MaskRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, MaskRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, MaskRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 53cb7ff275b..2fc6cdf318e 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,8 +18,8 @@ package org.apache.shardingsphere.readwritesplitting.metadata.nodepath; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration; import java.util.Arrays; @@ -28,7 +28,7 @@ import java.util.Collections; /** * Readwrite-splitting rule node path provider. */ -public final class ReadwriteSplittingRuleNodePathProvider implements RuleNodePathProvider { +public final class ReadwriteSplittingRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "readwrite_splitting"; @@ -36,10 +36,10 @@ public final class ReadwriteSplittingRuleNodePathProvider implements RuleNodePat public static final String LOAD_BALANCERS = "load_balancers"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Arrays.asList(DATA_SOURCE_GROUPS, LOAD_BALANCERS), Collections.emptyList()); + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(DATA_SOURCE_GROUPS, LOAD_BALANCERS), Collections.emptyList()); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 9ae5ab76067..2484748420d 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,8 +18,8 @@ package org.apache.shardingsphere.readwritesplitting.metadata.nodepath; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration; import org.junit.jupiter.api.Test; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class ReadwriteSplittingRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, ReadwriteSplittingRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, ReadwriteSplittingRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 d2b54e50ef2..14e3d2a5996 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,8 +18,8 @@ package org.apache.shardingsphere.shadow.metadata.nodepath; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration; import java.util.Arrays; @@ -28,7 +28,7 @@ import java.util.Collections; /** * Shadow rule node path provider. */ -public final class ShadowRuleNodePathProvider implements RuleNodePathProvider { +public final class ShadowRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "shadow"; @@ -40,10 +40,11 @@ public final class ShadowRuleNodePathProvider implements RuleNodePathProvider { public static final String DEFAULT_SHADOW_ALGORITHM_NAME = "default_shadow_algorithm_name"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Arrays.asList(DATA_SOURCES, TABLES, SHADOW_ALGORITHMS), Collections.singleton(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)); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 6aac5462239..3296816f641 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,8 +18,8 @@ package org.apache.shardingsphere.shadow.metadata.nodepath; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration; import org.junit.jupiter.api.Test; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class ShadowRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, ShadowRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, ShadowRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 9fab31bee24..c93cd4835c3 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,8 +18,8 @@ package org.apache.shardingsphere.sharding.metadata.nodepath; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration; import java.util.Arrays; @@ -27,7 +27,7 @@ import java.util.Arrays; /** * Sharding rule node path provider. */ -public final class ShardingRuleNodePathProvider implements RuleNodePathProvider { +public final class ShardingRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "sharding"; @@ -57,14 +57,14 @@ public final class ShardingRuleNodePathProvider implements RuleNodePathProvider private static final String DEFAULT_STRATEGIES_PREFIX = "default_strategies."; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Arrays.asList(TABLES, AUTO_TABLES, BINDING_TABLES, SHARDING_ALGORITHMS, KEY_GENERATORS, AUDITORS), Arrays.asList(DEFAULT_STRATEGIES_PREFIX + DEFAULT_DATABASE_STRATEGY, DEFAULT_STRATEGIES_PREFIX + DEFAULT_TABLE_STRATEGY, DEFAULT_STRATEGIES_PREFIX + DEFAULT_KEY_GENERATE_STRATEGY, DEFAULT_STRATEGIES_PREFIX + DEFAULT_AUDIT_STRATEGY, DEFAULT_STRATEGIES_PREFIX + DEFAULT_SHARDING_COLUMN, SHARDING_CACHE)); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 5372d1275d7..deef3b58716 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,8 +18,8 @@ package org.apache.shardingsphere.sharding.metadata.nodepath; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration; import org.hamcrest.collection.IsIterableContainingInAnyOrder; import org.junit.jupiter.api.Test; @@ -32,11 +32,11 @@ import static org.hamcrest.MatcherAssert.assertThat; class ShardingRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, ShardingRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, ShardingRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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 843da9ea6a3..9be4f577b36 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,8 +18,8 @@ package org.apache.shardingsphere.single.metadata.nodepath; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.single.config.SingleRuleConfiguration; import java.util.Arrays; @@ -28,7 +28,7 @@ import java.util.Collections; /** * Single rule node path provider. */ -public final class SingleRuleNodePathProvider implements RuleNodePathProvider { +public final class SingleRuleNodePathProvider implements DatabaseRuleNodePathProvider { public static final String RULE_TYPE = "single"; @@ -36,10 +36,10 @@ public final class SingleRuleNodePathProvider implements RuleNodePathProvider { public static final String DEFAULT_DATA_SOURCE = "default_data_source"; - private static final RuleNodePath INSTANCE = new RuleNodePath(RULE_TYPE, Collections.emptyList(), Arrays.asList(TABLES, DEFAULT_DATA_SOURCE)); + private static final DatabaseRuleNodePath INSTANCE = new DatabaseRuleNodePath(RULE_TYPE, Collections.emptyList(), Arrays.asList(TABLES, DEFAULT_DATA_SOURCE)); @Override - public RuleNodePath getRuleNodePath() { + public DatabaseRuleNodePath getDatabaseRuleNodePath() { return INSTANCE; } diff --git a/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 27eb07e1e69..99729b644ca 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,8 +18,8 @@ package org.apache.shardingsphere.single.metadata.nodepath; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.single.config.SingleRuleConfiguration; import org.junit.jupiter.api.Test; @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class SingleRuleNodePathProviderTest { - private final RuleNodePathProvider pathProvider = TypedSPILoader.getService(RuleNodePathProvider.class, SingleRuleConfiguration.class); + private final DatabaseRuleNodePathProvider pathProvider = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, SingleRuleConfiguration.class); @Test - void assertGetRuleNodePath() { - RuleNodePath actual = pathProvider.getRuleNodePath(); + void assertGetDatabaseRuleNodePath() { + DatabaseRuleNodePath 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/RuleItemChangedBuilder.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/RuleItemChangedBuilder.java index 25b20f80371..dd03b73de27 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/RuleItemChangedBuilder.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/changed/RuleItemChangedBuilder.java @@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.metadata.changed; import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader; import org.apache.shardingsphere.mode.metadata.changed.executor.RuleItemChangedBuildExecutor; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import org.apache.shardingsphere.mode.spi.rule.item.RuleChangedItem; import java.util.Optional; @@ -40,11 +40,11 @@ public final class RuleItemChangedBuilder { * @return built rule item */ public <T extends RuleChangedItem> Optional<T> build(final String databaseName, final String path, final Integer currentActiveVersion, final RuleItemChangedBuildExecutor<T> executor) { - for (RuleNodePathProvider each : ShardingSphereServiceLoader.getServiceInstances(RuleNodePathProvider.class)) { - if (!each.getRuleNodePath().getRoot().isValidatedPath(path)) { + for (DatabaseRuleNodePathProvider each : ShardingSphereServiceLoader.getServiceInstances(DatabaseRuleNodePathProvider.class)) { + if (!each.getDatabaseRuleNodePath().getRoot().isValidatedPath(path)) { continue; } - Optional<T> result = executor.build(each.getRuleNodePath(), databaseName, path, currentActiveVersion); + Optional<T> result = executor.build(each.getDatabaseRuleNodePath(), databaseName, path, currentActiveVersion); if (result.isPresent()) { return result; } 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 31ee34cf696..f332af53385 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.config.database.RuleNodePath; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; 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 ruleNodePath rule node path + * @param databaseRuleNodePath rule node path * @param databaseName database name * @param path path * @param currentActiveVersion current active version * @return built rule item */ - Optional<T> build(RuleNodePath ruleNodePath, String databaseName, String path, Integer currentActiveVersion); + Optional<T> build(DatabaseRuleNodePath databaseRuleNodePath, String databaseName, String path, Integer currentActiveVersion); } 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 80511b319b6..a89b49ecd4c 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.config.database.RuleNodePath; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; import org.apache.shardingsphere.mode.node.path.config.database.item.NamedRuleItemNodePath; import org.apache.shardingsphere.mode.node.path.config.database.item.UniqueRuleItemNodePath; 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 RuleNodePath ruleNodePath, final String databaseName, final String path, final Integer currentActiveVersion) { - for (Entry<String, NamedRuleItemNodePath> entry : ruleNodePath.getNamedItems().entrySet()) { + public Optional<AlterRuleItem> build(final DatabaseRuleNodePath databaseRuleNodePath, final String databaseName, final String path, final Integer currentActiveVersion) { + for (Entry<String, NamedRuleItemNodePath> entry : databaseRuleNodePath.getNamedItems().entrySet()) { Optional<String> itemName = entry.getValue().getVersionNodePathParser().findIdentifierByActiveVersionPath(path, 1); if (itemName.isPresent()) { - return Optional.of(new AlterNamedRuleItem(databaseName, itemName.get(), path, currentActiveVersion, ruleNodePath.getRoot().getRuleType() + "." + entry.getKey())); + return Optional.of(new AlterNamedRuleItem(databaseName, itemName.get(), path, currentActiveVersion, databaseRuleNodePath.getRoot().getRuleType() + "." + entry.getKey())); } } - for (Entry<String, UniqueRuleItemNodePath> entry : ruleNodePath.getUniqueItems().entrySet()) { + for (Entry<String, UniqueRuleItemNodePath> entry : databaseRuleNodePath.getUniqueItems().entrySet()) { if (entry.getValue().getVersionNodePathParser().isActiveVersionPath(path)) { - return Optional.of(new AlterUniqueRuleItem(databaseName, path, currentActiveVersion, ruleNodePath.getRoot().getRuleType() + "." + entry.getKey())); + return Optional.of(new AlterUniqueRuleItem(databaseName, path, currentActiveVersion, databaseRuleNodePath.getRoot().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 41e8c7929c7..5a99b218f2c 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.config.database.RuleNodePath; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; import org.apache.shardingsphere.mode.node.path.config.database.item.NamedRuleItemNodePath; import org.apache.shardingsphere.mode.node.path.config.database.item.UniqueRuleItemNodePath; 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 RuleNodePath ruleNodePath, final String databaseName, final String path, final Integer currentActiveVersion) { - for (Entry<String, NamedRuleItemNodePath> entry : ruleNodePath.getNamedItems().entrySet()) { + public Optional<DropRuleItem> build(final DatabaseRuleNodePath databaseRuleNodePath, final String databaseName, final String path, final Integer currentActiveVersion) { + for (Entry<String, NamedRuleItemNodePath> entry : databaseRuleNodePath.getNamedItems().entrySet()) { Optional<String> itemName = entry.getValue().findNameByItemPath(path); if (itemName.isPresent()) { - return Optional.of(new DropNamedRuleItem(databaseName, itemName.get(), ruleNodePath.getRoot().getRuleType() + "." + entry.getKey())); + return Optional.of(new DropNamedRuleItem(databaseName, itemName.get(), databaseRuleNodePath.getRoot().getRuleType() + "." + entry.getKey())); } } - for (Entry<String, UniqueRuleItemNodePath> entry : ruleNodePath.getUniqueItems().entrySet()) { + for (Entry<String, UniqueRuleItemNodePath> entry : databaseRuleNodePath.getUniqueItems().entrySet()) { if (entry.getValue().getVersionNodePathParser().isActiveVersionPath(path)) { - return Optional.of(new DropUniqueRuleItem(databaseName, ruleNodePath.getRoot().getRuleType() + "." + entry.getKey())); + return Optional.of(new DropUniqueRuleItem(databaseName, databaseRuleNodePath.getRoot().getRuleType() + "." + entry.getKey())); } } return Optional.empty(); diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/DatabaseRuleNodePath.java similarity index 93% rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePath.java rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/DatabaseRuleNodePath.java index 6e777e8c78e..d543d19b041 100644 --- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePath.java +++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/DatabaseRuleNodePath.java @@ -27,10 +27,10 @@ import java.util.HashMap; import java.util.Map; /** - * Rule node path. + * Database rule node path. */ @Getter -public final class RuleNodePath { +public final class DatabaseRuleNodePath { private final RuleRootNodePath root; @@ -38,7 +38,7 @@ public final class RuleNodePath { private final Map<String, UniqueRuleItemNodePath> uniqueItems; - public RuleNodePath(final String ruleType, final Collection<String> namedRuleItemNodePathTypes, final Collection<String> uniqueRuleItemNodePathTypes) { + public DatabaseRuleNodePath(final String ruleType, final Collection<String> namedRuleItemNodePathTypes, final Collection<String> uniqueRuleItemNodePathTypes) { root = new RuleRootNodePath(ruleType); namedItems = getNamedRuleItemNodePathMap(namedRuleItemNodePathTypes); uniqueItems = getUniqueRuleItemNodePathMap(uniqueRuleItemNodePathTypes); diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/RuleNodePathProvider.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java similarity index 82% rename from mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/RuleNodePathProvider.java rename to mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java index 736e7fde6d7..70d2abca83e 100644 --- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/RuleNodePathProvider.java +++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/spi/DatabaseRuleNodePathProvider.java @@ -20,20 +20,20 @@ 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.config.database.RuleNodePath; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; /** - * Rule node path provider. + * Database rule node path provider. */ @SingletonSPI -public interface RuleNodePathProvider extends TypedSPI { +public interface DatabaseRuleNodePathProvider extends TypedSPI { /** - * Get rule node path. + * Get database rule node path. * - * @return got rule node path + * @return got database rule node path */ - RuleNodePath getRuleNodePath(); + DatabaseRuleNodePath 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 99f68501341..61d50abc2d9 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,8 @@ 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.config.global.GlobalRuleNodePath; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.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; import org.apache.shardingsphere.mode.node.tuple.annotation.RepositoryTupleKeyListNameGenerator; @@ -70,11 +70,11 @@ public final class YamlRepositoryTupleSwapperEngine { return Collections.singleton(new RepositoryTuple(tupleEntity.value(), YamlEngine.marshal(yamlRuleConfig))); } Collection<RepositoryTuple> result = new LinkedList<>(); - RuleNodePath ruleNodePath = TypedSPILoader.getService(RuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getRuleNodePath(); + DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath(); for (Field each : getFields(yamlRuleConfig.getClass())) { boolean isAccessible = each.isAccessible(); each.setAccessible(true); - result.addAll(swapToRepositoryTuples(yamlRuleConfig, ruleNodePath, each)); + result.addAll(swapToRepositoryTuples(yamlRuleConfig, databaseRuleNodePath, each)); each.setAccessible(isAccessible); } return result; @@ -82,7 +82,7 @@ public final class YamlRepositoryTupleSwapperEngine { @SneakyThrows(ReflectiveOperationException.class) @SuppressWarnings("rawtypes") - private Collection<RepositoryTuple> swapToRepositoryTuples(final YamlRuleConfiguration yamlRuleConfig, final RuleNodePath ruleNodePath, final Field field) { + private Collection<RepositoryTuple> swapToRepositoryTuples(final YamlRuleConfiguration yamlRuleConfig, final DatabaseRuleNodePath databaseRuleNodePath, final Field field) { Object fieldValue = field.get(yamlRuleConfig); if (null == fieldValue) { return Collections.emptyList(); @@ -93,32 +93,34 @@ 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(ruleNodePath.getNamedItem(tupleName).getPath(tupleKeyName), value.toString())); + result.add(new RepositoryTuple(databaseRuleNodePath.getNamedItem(tupleName).getPath(tupleKeyName), value.toString())); } return result; } if (fieldValue instanceof Map) { Collection<RepositoryTuple> result = new LinkedList<>(); for (Object entry : ((Map) fieldValue).entrySet()) { - result.add(new RepositoryTuple(ruleNodePath.getNamedItem(tupleName).getPath(((Entry) entry).getKey().toString()), YamlEngine.marshal(((Entry) entry).getValue()))); + result.add(new RepositoryTuple(databaseRuleNodePath.getNamedItem(tupleName).getPath(((Entry) entry).getKey().toString()), YamlEngine.marshal(((Entry) entry).getValue()))); } return result; } if (fieldValue instanceof Collection) { return ((Collection) fieldValue).isEmpty() ? Collections.emptyList() - : Collections.singleton(new RepositoryTuple(ruleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue))); + : Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue))); } if (fieldValue instanceof String) { - return ((String) fieldValue).isEmpty() ? Collections.emptyList() : Collections.singleton(new RepositoryTuple(ruleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString())); + return ((String) fieldValue).isEmpty() + ? Collections.emptyList() + : Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString())); } if (fieldValue instanceof Boolean || fieldValue instanceof Integer || fieldValue instanceof Long) { - return Collections.singleton(new RepositoryTuple(ruleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString())); + return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), fieldValue.toString())); } if (fieldValue instanceof Enum) { - return Collections.singleton(new RepositoryTuple(ruleNodePath.getUniqueItem(tupleName).getPath(), ((Enum) fieldValue).name())); + return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), ((Enum) fieldValue).name())); } - return Collections.singleton(new RepositoryTuple(ruleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue))); + return Collections.singleton(new RepositoryTuple(databaseRuleNodePath.getUniqueItem(tupleName).getPath(), YamlEngine.marshal(fieldValue))); } private Collection<Field> getFields(final Class<? extends YamlRuleConfiguration> yamlRuleConfigurationClass) { @@ -160,9 +162,9 @@ public final class YamlRepositoryTupleSwapperEngine { return Optional.empty(); } YamlRuleConfiguration yamlRuleConfig = toBeSwappedType.getConstructor().newInstance(); - RuleNodePath ruleNodePath = TypedSPILoader.getService(RuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getRuleNodePath(); - for (RepositoryTuple each : repositoryTuples.stream().filter(each -> ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList())) { - if (ruleNodePath.getUniqueItem(tupleEntity.value()).getVersionNodePathParser().isVersionPath(each.getKey())) { + DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath(); + for (RepositoryTuple each : repositoryTuples.stream().filter(each -> databaseRuleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList())) { + if (databaseRuleNodePath.getUniqueItem(tupleEntity.value()).getVersionNodePathParser().isVersionPath(each.getKey())) { return Optional.of(YamlEngine.unmarshal(each.getValue(), toBeSwappedType)); } } @@ -173,46 +175,47 @@ 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(); - RuleNodePath ruleNodePath = TypedSPILoader.getService(RuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getRuleNodePath(); - List<RepositoryTuple> validTuples = repositoryTuples.stream().filter(each -> ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList()); + DatabaseRuleNodePath databaseRuleNodePath = TypedSPILoader.getService(DatabaseRuleNodePathProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNodePath(); + List<RepositoryTuple> validTuples = repositoryTuples.stream().filter(each -> databaseRuleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList()); if (validTuples.isEmpty()) { return Optional.empty(); } for (RepositoryTuple each : validTuples) { if (!Strings.isNullOrEmpty(each.getValue())) { - setFieldValue(yamlRuleConfig, fields, ruleNodePath, each); + setFieldValue(yamlRuleConfig, fields, databaseRuleNodePath, each); } } return Optional.of(yamlRuleConfig); } @SneakyThrows(ReflectiveOperationException.class) - private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Collection<Field> fields, final RuleNodePath ruleNodePath, final RepositoryTuple repositoryTuple) { + private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Collection<Field> fields, final DatabaseRuleNodePath databaseRuleNodePath, final RepositoryTuple repositoryTuple) { for (Field each : fields) { boolean isAccessible = each.isAccessible(); each.setAccessible(true); - setFieldValue(yamlRuleConfig, each, ruleNodePath, repositoryTuple); + setFieldValue(yamlRuleConfig, each, databaseRuleNodePath, repositoryTuple); each.setAccessible(isAccessible); } } @SuppressWarnings({"unchecked", "rawtypes"}) - private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Field field, final RuleNodePath ruleNodePath, final RepositoryTuple repositoryTuple) throws IllegalAccessException { + private void setFieldValue(final YamlRuleConfiguration yamlRuleConfig, final Field field, final DatabaseRuleNodePath databaseRuleNodePath, + 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) { - ruleNodePath.getNamedItem(tupleName).getVersionNodePathParser() + databaseRuleNodePath.getNamedItem(tupleName).getVersionNodePathParser() .findIdentifierByVersionsPath(repositoryTuple.getKey(), 1).ifPresent(optional -> ((Collection) fieldValue).add(repositoryTuple.getValue())); return; } if (fieldValue instanceof Map) { Class<?> valueClass = (Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1]; - ruleNodePath.getNamedItem(tupleName).getVersionNodePathParser().findIdentifierByVersionsPath(repositoryTuple.getKey(), 1) + databaseRuleNodePath.getNamedItem(tupleName).getVersionNodePathParser().findIdentifierByVersionsPath(repositoryTuple.getKey(), 1) .ifPresent(optional -> ((Map) fieldValue).put(optional, YamlEngine.unmarshal(repositoryTuple.getValue(), valueClass))); return; } - if (!ruleNodePath.getUniqueItem(tupleName).getVersionNodePathParser().isVersionPath(repositoryTuple.getKey())) { + if (!databaseRuleNodePath.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/config/database/RuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePathTest.java index 087b76b02cf..b043b077e5d 100644 --- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePathTest.java +++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/RuleNodePathTest.java @@ -31,26 +31,26 @@ import static org.hamcrest.MatcherAssert.assertThat; class RuleNodePathTest { - private RuleNodePath ruleNodePath; + private DatabaseRuleNodePath databaseRuleNodePath; @BeforeEach void setup() { List<String> namedRuleItemNodePathTypes = Collections.singletonList("tables"); List<String> uniqueRuleItemNodePathTypes = Arrays.asList("tables", "tables.type"); - ruleNodePath = new RuleNodePath("foo", namedRuleItemNodePathTypes, uniqueRuleItemNodePathTypes); + databaseRuleNodePath = new DatabaseRuleNodePath("foo", namedRuleItemNodePathTypes, uniqueRuleItemNodePathTypes); } @Test void assertFindNameByVersion() { - NamedRuleItemNodePath namedRulePath = ruleNodePath.getNamedItem("tables"); + NamedRuleItemNodePath namedRulePath = databaseRuleNodePath.getNamedItem("tables"); assertThat(namedRulePath.getPath("foo_tbl"), is("tables/foo_tbl")); } @Test void assertGetUniqueItem() { - UniqueRuleItemNodePath uniqueRulePath = ruleNodePath.getUniqueItem("tables"); + UniqueRuleItemNodePath uniqueRulePath = databaseRuleNodePath.getUniqueItem("tables"); assertThat(uniqueRulePath.getPath(), is("tables")); - UniqueRuleItemNodePath uniqueRulePathWithType = ruleNodePath.getUniqueItem("type"); + UniqueRuleItemNodePath uniqueRulePathWithType = databaseRuleNodePath.getUniqueItem("type"); assertThat(uniqueRulePathWithType.getPath(), is("tables/type")); } } 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 e7284b98ea3..c17fae808c4 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,16 +18,16 @@ package org.apache.shardingsphere.mode.node.tuple.fixture.node; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.mode.node.path.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +import org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider; import java.util.Arrays; -public final class RuleNodePathProviderFixture implements RuleNodePathProvider { +public final class RuleNodePathProviderFixture implements DatabaseRuleNodePathProvider { @Override - public RuleNodePath getRuleNodePath() { - return new RuleNodePath("node", Arrays.asList("map_value", "gens"), + public DatabaseRuleNodePath getDatabaseRuleNodePath() { + return new DatabaseRuleNodePath("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/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider b/mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider similarity index 100% rename from mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider rename to mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.spi.DatabaseRuleNodePathProvider 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 541b0ce216f..c5bb282093d 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,8 +21,8 @@ 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.config.database.RuleNodePath; -import org.apache.shardingsphere.mode.node.spi.RuleNodePathProvider; +import org.apache.shardingsphere.mode.node.path.config.database.DatabaseRuleNodePath; +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; import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem; @@ -57,9 +57,9 @@ class RuleConfigurationChangedHandlerTest { @BeforeEach void setUp() { handler = new RuleConfigurationChangedHandler(contextManager); - RuleNodePathProvider ruleNodePathProvider = mock(RuleNodePathProvider.class, RETURNS_DEEP_STUBS); - when(ruleNodePathProvider.getRuleNodePath()).thenReturn(new RuleNodePath("foo_rule", Collections.singleton("named"), Collections.singleton("unique"))); - when(ShardingSphereServiceLoader.getServiceInstances(RuleNodePathProvider.class)).thenReturn(Collections.singleton(ruleNodePathProvider)); + DatabaseRuleNodePathProvider databaseRuleNodePathProvider = mock(DatabaseRuleNodePathProvider.class, RETURNS_DEEP_STUBS); + when(databaseRuleNodePathProvider.getDatabaseRuleNodePath()).thenReturn(new DatabaseRuleNodePath("foo_rule", Collections.singleton("named"), Collections.singleton("unique"))); + when(ShardingSphereServiceLoader.getServiceInstances(DatabaseRuleNodePathProvider.class)).thenReturn(Collections.singleton(databaseRuleNodePathProvider)); } @Test