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/26 17:25:29 UTC
(shardingsphere) branch master updated: Add DatabaseRuleNodeGenerator (#34797)
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 20446a75424 Add DatabaseRuleNodeGenerator (#34797)
20446a75424 is described below
commit 20446a75424efb25077f43adfdcc1851129ff413
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Feb 27 01:25:23 2025 +0800
Add DatabaseRuleNodeGenerator (#34797)
* Add DatabaseRuleNodeGenerator
* Add DatabaseRuleNodeGenerator
* Add DatabaseRuleNodeGenerator
* Add DatabaseRuleNodeGenerator
* Add DatabaseRuleNodeGenerator
---
.../nodepath/BroadcastRuleNodeProvider.java | 47 -------------
.../changed/BroadcastTableChangedProcessor.java | 5 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/BroadcastRuleNodeProviderTest.java | 42 ------------
.../metadata/nodepath/EncryptRuleNodeProvider.java | 50 --------------
.../rule/changed/EncryptTableChangedProcessor.java | 5 +-
.../rule/changed/EncryptorChangedProcessor.java | 3 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/EncryptRuleNodeProviderTest.java | 43 ------------
.../metadata/nodepath/MaskRuleNodeProvider.java | 50 --------------
.../changed/MaskAlgorithmChangedProcessor.java | 5 +-
.../rule/changed/MaskTableChangedProcessor.java | 5 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/MaskRuleNodeProviderTest.java | 43 ------------
.../ReadwriteSplittingRuleNodeProvider.java | 50 --------------
...adwriteSplittingDataSourceChangedProcessor.java | 5 +-
...writeSplittingLoadBalancerChangedProcessor.java | 3 +-
...ReadwriteSplittingRuleConfigurationSwapper.java | 2 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../ReadwriteSplittingRuleNodeProviderTest.java | 43 ------------
.../metadata/nodepath/ShadowRuleNodeProvider.java | 55 ----------------
...DefaultShadowAlgorithmNameChangedProcessor.java | 5 +-
.../changed/ShadowAlgorithmChangedProcessor.java | 3 +-
.../changed/ShadowDataSourceChangedProcessor.java | 5 +-
.../rule/changed/ShadowTableChangedProcessor.java | 5 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/ShadowRuleNodeProviderTest.java | 45 -------------
.../nodepath/ShardingRuleNodeProvider.java | 71 --------------------
...ltDatabaseShardingStrategyChangedProcessor.java | 5 +-
...DefaultKeyGenerateStrategyChangedProcessor.java | 5 +-
...ultShardingAuditorStrategyChangedProcessor.java | 5 +-
.../DefaultShardingColumnChangedProcessor.java | 5 +-
...faultTableShardingStrategyChangedProcessor.java | 5 +-
.../rule/changed/KeyGeneratorChangedProcessor.java | 3 +-
.../changed/ShardingAlgorithmChangedProcessor.java | 3 +-
.../changed/ShardingAuditorChangedProcessor.java | 3 +-
.../changed/ShardingAutoTableChangedProcessor.java | 5 +-
.../changed/ShardingCacheChangedProcessor.java | 5 +-
.../changed/ShardingTableChangedProcessor.java | 5 +-
.../ShardingTableReferenceChangedProcessor.java | 5 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/ShardingRuleNodeProviderTest.java | 51 ---------------
.../metadata/nodepath/SingleRuleNodeProvider.java | 50 --------------
.../changed/DefaultDataSourceChangedProcessor.java | 5 +-
.../rule/changed/SingleTableChangedProcessor.java | 5 +-
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../nodepath/SingleRuleNodeProviderTest.java | 43 ------------
.../metadata/changed/RuleItemChangedBuilder.java | 37 +++++++++--
.../type/metadata/rule/DatabaseRuleNodePath.java | 9 +++
.../node/rule/node/DatabaseRuleNodeGenerator.java | 76 ++++++++++++++++++++++
.../node/rule/node/DatabaseRuleNodeProvider.java | 39 -----------
.../YamlRuleRepositoryTupleSwapperEngine.java | 7 +-
.../rule/fixture/node/RuleNodeProviderFixture.java | 38 -----------
.../fixture/none/NoneYamlRuleConfiguration.java | 2 +
...re.mode.node.rule.node.DatabaseRuleNodeProvider | 18 -----
.../rule/RuleConfigurationChangedHandlerTest.java | 16 +----
.../cluster/fixture/RuleConfigurationFixture.java | 6 +-
.../fixture/YamlRuleConfigurationFixture.java | 12 +++-
.../YamlRuleConfigurationSwapperFixture.java | 6 +-
59 files changed, 188 insertions(+), 1002 deletions(-)
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProvider.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProvider.java
deleted file mode 100644
index 638bf39df1f..00000000000
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.broadcast.metadata.nodepath;
-
-import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-
-import java.util.Collections;
-
-/**
- * Broadcast rule node provider.
- */
-public final class BroadcastRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "broadcast";
-
- public static final String TABLES = "tables";
-
- private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Collections.emptyList(), Collections.singleton(TABLES));
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return BroadcastRuleConfiguration.class;
- }
-}
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
index 7acf38c7cb0..1ae7bfe0e1f 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
@@ -18,13 +18,12 @@
package org.apache.shardingsphere.broadcast.rule.changed;
import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
-import org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodeProvider;
import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -58,6 +57,6 @@ public final class BroadcastTableChangedProcessor implements RuleItemConfigurati
@Override
public String getType() {
- return BroadcastRuleNodeProvider.RULE_TYPE + "." + BroadcastRuleNodeProvider.TABLES;
+ return "broadcast.tables";
}
}
diff --git a/features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 3055a6b9081..00000000000
--- a/features/broadcast/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodeProvider
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProviderTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProviderTest.java
deleted file mode 100644
index 1efc4ee5c34..00000000000
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/metadata/nodepath/BroadcastRuleNodeProviderTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.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.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class BroadcastRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, BroadcastRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertTrue(actual.getNamedItems().isEmpty());
- assertThat(actual.getUniqueItems().size(), is(1));
- assertTrue(actual.getUniqueItems().contains(BroadcastRuleNodeProvider.TABLES));
- assertThat(actual.getRuleType(), is(BroadcastRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProvider.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProvider.java
deleted file mode 100644
index 78de885e8fd..00000000000
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.metadata.nodepath;
-
-import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Encrypt rule node provider.
- */
-public final class EncryptRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "encrypt";
-
- public static final String TABLES = "tables";
-
- public static final String ENCRYPTORS = "encryptors";
-
- private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(TABLES, ENCRYPTORS), Collections.emptyList());
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return EncryptRuleConfiguration.class;
- }
-}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java
index 7fd03bdab6f..b57d9119576 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java
@@ -19,16 +19,15 @@ package org.apache.shardingsphere.encrypt.rule.changed;
import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodeProvider;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.yaml.swapper.rule.YamlEncryptTableRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -63,6 +62,6 @@ public final class EncryptTableChangedProcessor implements RuleItemConfiguration
@Override
public String getType() {
- return EncryptRuleNodeProvider.RULE_TYPE + "." + EncryptRuleNodeProvider.TABLES;
+ return "encrypt.tables";
}
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessor.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessor.java
index 648a57a1dea..307c00fad47 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessor.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessor.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.rule.changed;
import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodeProvider;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
@@ -48,6 +47,6 @@ public final class EncryptorChangedProcessor extends AlgorithmChangedProcessor<E
@Override
public String getType() {
- return EncryptRuleNodeProvider.RULE_TYPE + "." + EncryptRuleNodeProvider.ENCRYPTORS;
+ return "encrypt.encryptors";
}
}
diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index a53a15594a1..00000000000
--- a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodeProvider
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProviderTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProviderTest.java
deleted file mode 100644
index fde1392967d..00000000000
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/metadata/nodepath/EncryptRuleNodeProviderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.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.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class EncryptRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, EncryptRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertThat(actual.getNamedItems().size(), is(2));
- assertTrue(actual.getNamedItems().contains(EncryptRuleNodeProvider.ENCRYPTORS));
- assertTrue(actual.getNamedItems().contains(EncryptRuleNodeProvider.TABLES));
- assertTrue(actual.getUniqueItems().isEmpty());
- assertThat(actual.getRuleType(), is(EncryptRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProvider.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProvider.java
deleted file mode 100644
index 7bd65b3a14e..00000000000
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mask.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Mask rule node provider.
- */
-public final class MaskRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "mask";
-
- public static final String TABLES = "tables";
-
- public static final String MASK_ALGORITHMS = "mask_algorithms";
-
- private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(TABLES, MASK_ALGORITHMS), Collections.emptyList());
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return MaskRuleConfiguration.class;
- }
-}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessor.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessor.java
index ffc3a4843ad..be4f257ccbe 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessor.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessor.java
@@ -18,10 +18,9 @@
package org.apache.shardingsphere.mask.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodeProvider;
import org.apache.shardingsphere.mask.rule.MaskRule;
-import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -48,6 +47,6 @@ public final class MaskAlgorithmChangedProcessor extends AlgorithmChangedProcess
@Override
public String getType() {
- return MaskRuleNodeProvider.RULE_TYPE + "." + MaskRuleNodeProvider.MASK_ALGORITHMS;
+ return "mask.mask_algorithms";
}
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessor.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessor.java
index 4d7fd0d002a..d356868903c 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessor.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessor.java
@@ -21,14 +21,13 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration;
-import org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodeProvider;
import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
import org.apache.shardingsphere.mask.yaml.swapper.rule.YamlMaskTableRuleConfigurationSwapper;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -62,6 +61,6 @@ public final class MaskTableChangedProcessor implements RuleItemConfigurationCha
@Override
public String getType() {
- return MaskRuleNodeProvider.RULE_TYPE + "." + MaskRuleNodeProvider.TABLES;
+ return "mask.tables";
}
}
diff --git a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index d50ccac01fc..00000000000
--- a/features/mask/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodeProvider
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProviderTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProviderTest.java
deleted file mode 100644
index 58c691c6a0e..00000000000
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/metadata/nodepath/MaskRuleNodeProviderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.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.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class MaskRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, MaskRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertThat(actual.getNamedItems().size(), is(2));
- assertTrue(actual.getNamedItems().contains(MaskRuleNodeProvider.MASK_ALGORITHMS));
- assertTrue(actual.getNamedItems().contains(MaskRuleNodeProvider.TABLES));
- assertTrue(actual.getUniqueItems().isEmpty());
- assertThat(actual.getRuleType(), is(MaskRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProvider.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProvider.java
deleted file mode 100644
index e27af72ab80..00000000000
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.readwritesplitting.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Readwrite-splitting rule node provider.
- */
-public final class ReadwriteSplittingRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "readwrite_splitting";
-
- public static final String DATA_SOURCE_GROUPS = "data_source_groups";
-
- public static final String LOAD_BALANCERS = "load_balancers";
-
- private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Arrays.asList(DATA_SOURCE_GROUPS, LOAD_BALANCERS), Collections.emptyList());
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return ReadwriteSplittingRuleConfiguration.class;
- }
-}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java
index 92488e4dfc6..53348cd9554 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java
@@ -20,14 +20,13 @@ package org.apache.shardingsphere.readwritesplitting.rule.changed;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodeProvider;
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy;
import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
@@ -76,6 +75,6 @@ public final class ReadwriteSplittingDataSourceChangedProcessor
@Override
public String getType() {
- return ReadwriteSplittingRuleNodeProvider.RULE_TYPE + "." + ReadwriteSplittingRuleNodeProvider.DATA_SOURCE_GROUPS;
+ return "readwrite_splitting.data_source_groups";
}
}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessor.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessor.java
index a0bc62bb686..222eb2d679b 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessor.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessor.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.readwritesplitting.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodeProvider;
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
import java.util.LinkedHashMap;
@@ -48,6 +47,6 @@ public final class ReadwriteSplittingLoadBalancerChangedProcessor extends Algori
@Override
public String getType() {
- return ReadwriteSplittingRuleNodeProvider.RULE_TYPE + "." + ReadwriteSplittingRuleNodeProvider.LOAD_BALANCERS;
+ return "readwrite_splitting.load_balancers";
}
}
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapper.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapper.java
index 78b83366f81..e3e3f721cce 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapper.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapper.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigur
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy;
import org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
+import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy;
import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
diff --git a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 9a904474731..00000000000
--- a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodeProvider
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProviderTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProviderTest.java
deleted file mode 100644
index 2369c0567c1..00000000000
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/metadata/nodepath/ReadwriteSplittingRuleNodeProviderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.readwritesplitting.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class ReadwriteSplittingRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, ReadwriteSplittingRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertThat(actual.getNamedItems().size(), is(2));
- assertTrue(actual.getNamedItems().contains(ReadwriteSplittingRuleNodeProvider.DATA_SOURCE_GROUPS));
- assertTrue(actual.getNamedItems().contains(ReadwriteSplittingRuleNodeProvider.LOAD_BALANCERS));
- assertTrue(actual.getUniqueItems().isEmpty());
- assertThat(actual.getRuleType(), is(ReadwriteSplittingRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProvider.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProvider.java
deleted file mode 100644
index d88f14dd11a..00000000000
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.shadow.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Shadow rule node provider.
- */
-public final class ShadowRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "shadow";
-
- public static final String DATA_SOURCES = "data_sources";
-
- public static final String TABLES = "tables";
-
- public static final String SHADOW_ALGORITHMS = "shadow_algorithms";
-
- public static final String DEFAULT_SHADOW_ALGORITHM_NAME = "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 DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return ShadowRuleConfiguration.class;
- }
-}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/DefaultShadowAlgorithmNameChangedProcessor.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/DefaultShadowAlgorithmNameChangedProcessor.java
index 564d1695b5f..0b2456c5757 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/DefaultShadowAlgorithmNameChangedProcessor.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/DefaultShadowAlgorithmNameChangedProcessor.java
@@ -18,11 +18,10 @@
package org.apache.shardingsphere.shadow.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
-import org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodeProvider;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
/**
@@ -52,6 +51,6 @@ public final class DefaultShadowAlgorithmNameChangedProcessor implements RuleIte
@Override
public String getType() {
- return ShadowRuleNodeProvider.RULE_TYPE + "." + ShadowRuleNodeProvider.DEFAULT_SHADOW_ALGORITHM_NAME;
+ return "shadow.default_shadow_algorithm_name";
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessor.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessor.java
index c3074c9c361..ad88123d664 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessor.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessor.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.shadow.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
-import org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodeProvider;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
import java.util.Map;
@@ -46,6 +45,6 @@ public final class ShadowAlgorithmChangedProcessor extends AlgorithmChangedProce
@Override
public String getType() {
- return ShadowRuleNodeProvider.RULE_TYPE + "." + ShadowRuleNodeProvider.SHADOW_ALGORITHMS;
+ return "shadow.shadow_algorithms";
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessor.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessor.java
index 18e02ae9f11..fb02b4ff19d 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessor.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessor.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.shadow.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration;
-import org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodeProvider;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
import org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
@@ -60,6 +59,6 @@ public final class ShadowDataSourceChangedProcessor implements RuleItemConfigura
@Override
public String getType() {
- return ShadowRuleNodeProvider.RULE_TYPE + "." + ShadowRuleNodeProvider.DATA_SOURCES;
+ return "shadow.data_sources";
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessor.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessor.java
index cafe70c143a..3a87629b92f 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessor.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessor.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.shadow.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration;
-import org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodeProvider;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
import org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
import org.apache.shardingsphere.shadow.yaml.swapper.table.YamlShadowTableConfigurationSwapper;
@@ -58,6 +57,6 @@ public final class ShadowTableChangedProcessor implements RuleItemConfigurationC
@Override
public String getType() {
- return ShadowRuleNodeProvider.RULE_TYPE + "." + ShadowRuleNodeProvider.TABLES;
+ return "shadow.tables";
}
}
diff --git a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 4bef24a98a1..00000000000
--- a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodeProvider
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProviderTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProviderTest.java
deleted file mode 100644
index 97bf95acb0f..00000000000
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/metadata/nodepath/ShadowRuleNodeProviderTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.shadow.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class ShadowRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, ShadowRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertThat(actual.getNamedItems().size(), is(3));
- assertTrue(actual.getNamedItems().contains(ShadowRuleNodeProvider.SHADOW_ALGORITHMS));
- assertTrue(actual.getNamedItems().contains(ShadowRuleNodeProvider.TABLES));
- assertTrue(actual.getNamedItems().contains(ShadowRuleNodeProvider.DATA_SOURCES));
- assertThat(actual.getUniqueItems().size(), is(1));
- assertTrue(actual.getUniqueItems().contains(ShadowRuleNodeProvider.DEFAULT_SHADOW_ALGORITHM_NAME));
- assertThat(actual.getRuleType(), is(ShadowRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProvider.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProvider.java
deleted file mode 100644
index 22cb473d163..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProvider.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-
-import java.util.Arrays;
-
-/**
- * Sharding rule node provider.
- */
-public final class ShardingRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "sharding";
-
- public static final String TABLES = "tables";
-
- public static final String AUTO_TABLES = "auto_tables";
-
- public static final String BINDING_TABLES = "binding_tables";
-
- public static final String SHARDING_ALGORITHMS = "sharding_algorithms";
-
- public static final String KEY_GENERATORS = "key_generators";
-
- public static final String AUDITORS = "auditors";
-
- public static final String DEFAULT_DATABASE_STRATEGY = "default_database_strategy";
-
- public static final String DEFAULT_TABLE_STRATEGY = "default_table_strategy";
-
- public static final String DEFAULT_KEY_GENERATE_STRATEGY = "default_key_generate_strategy";
-
- public static final String DEFAULT_AUDIT_STRATEGY = "default_audit_strategy";
-
- public static final String DEFAULT_SHARDING_COLUMN = "default_sharding_column";
-
- public static final String SHARDING_CACHE = "sharding_cache";
-
- 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 DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return ShardingRuleConfiguration.class;
- }
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessor.java
index 1e8799c3cb2..a3526bc8036 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessor.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingStrategyConfigurationSwapper;
@@ -56,6 +55,6 @@ public final class DefaultDatabaseShardingStrategyChangedProcessor implements Ru
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.DEFAULT_DATABASE_STRATEGY;
+ return "sharding.default_database_strategy";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessor.java
index ddb04baa2f1..e87847b1a2d 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessor.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlKeyGenerateStrategyConfigurationSwapper;
@@ -56,6 +55,6 @@ public final class DefaultKeyGenerateStrategyChangedProcessor implements RuleIte
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.DEFAULT_KEY_GENERATE_STRATEGY;
+ return "sharding.default_key_generate_strategy";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessor.java
index 985a23b20d6..4ac7004cdf7 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessor.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingAuditStrategyConfigurationSwapper;
@@ -56,6 +55,6 @@ public final class DefaultShardingAuditorStrategyChangedProcessor implements Rul
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.DEFAULT_AUDIT_STRATEGY;
+ return "sharding.default_audit_strategy";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingColumnChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingColumnChangedProcessor.java
index ee434c0bb6d..baf6574d244 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingColumnChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingColumnChangedProcessor.java
@@ -18,11 +18,10 @@
package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
/**
@@ -52,6 +51,6 @@ public final class DefaultShardingColumnChangedProcessor implements RuleItemConf
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.DEFAULT_SHARDING_COLUMN;
+ return "sharding.default_sharding_column";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessor.java
index aebe1c37ceb..933fcdd07fd 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessor.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.strategy.YamlShardingStrategyConfigurationSwapper;
@@ -56,6 +55,6 @@ public final class DefaultTableShardingStrategyChangedProcessor implements RuleI
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.DEFAULT_TABLE_STRATEGY;
+ return "sharding.default_table_strategy";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessor.java
index 194977257e9..df72a18fb46 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessor.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import java.util.Map;
@@ -46,6 +45,6 @@ public final class KeyGeneratorChangedProcessor extends AlgorithmChangedProcesso
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.KEY_GENERATORS;
+ return "sharding.key_generators";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessor.java
index 39560ed227f..d378fe20544 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessor.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import java.util.Map;
@@ -46,6 +45,6 @@ public final class ShardingAlgorithmChangedProcessor extends AlgorithmChangedPro
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.SHARDING_ALGORITHMS;
+ return "sharding.sharding_algorithms";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessor.java
index 909a389174e..ecf33eb59a7 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessor.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.processor.AlgorithmChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import java.util.Map;
@@ -46,6 +45,6 @@ public final class ShardingAuditorChangedProcessor extends AlgorithmChangedProce
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.AUDITORS;
+ return "sharding.auditors";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessor.java
index c0b7cd9549b..29f46403b5f 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessor.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingAutoTableRuleConfigurationSwapper;
@@ -59,6 +58,6 @@ public final class ShardingAutoTableChangedProcessor implements RuleItemConfigur
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.AUTO_TABLES;
+ return "sharding.auto_tables";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingCacheChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingCacheChangedProcessor.java
index 977e00cfda7..47c34c1f531 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingCacheChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingCacheChangedProcessor.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.cache.YamlShardingCacheConfigurationSwapper;
@@ -56,6 +55,6 @@ public final class ShardingCacheChangedProcessor implements RuleItemConfiguratio
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.SHARDING_CACHE;
+ return "sharding.sharding_cache";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessor.java
index c1d300bab55..6319ee6bf38 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessor.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableRuleConfigurationSwapper;
@@ -59,6 +58,6 @@ public final class ShardingTableChangedProcessor implements RuleItemConfiguratio
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.TABLES;
+ return "sharding.tables";
}
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessor.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessor.java
index 88c3bc909bd..7e5a04ce109 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessor.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessor.java
@@ -18,14 +18,13 @@
package org.apache.shardingsphere.sharding.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropNamedRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
-import org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableReferenceRuleConfigurationConverter;
@@ -57,6 +56,6 @@ public final class ShardingTableReferenceChangedProcessor implements RuleItemCon
@Override
public String getType() {
- return ShardingRuleNodeProvider.RULE_TYPE + "." + ShardingRuleNodeProvider.BINDING_TABLES;
+ return "sharding.binding_tables";
}
}
diff --git a/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 250f05a6938..00000000000
--- a/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodeProvider
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProviderTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProviderTest.java
deleted file mode 100644
index acb256f54fd..00000000000
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/nodepath/ShardingRuleNodeProviderTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sharding.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.hamcrest.collection.IsIterableContainingInAnyOrder;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ShardingRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, ShardingRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertThat(actual.getNamedItems().size(), is(6));
- List<String> namedRuleItems = Arrays.asList(ShardingRuleNodeProvider.TABLES, ShardingRuleNodeProvider.AUTO_TABLES, ShardingRuleNodeProvider.BINDING_TABLES,
- ShardingRuleNodeProvider.SHARDING_ALGORITHMS, ShardingRuleNodeProvider.KEY_GENERATORS, ShardingRuleNodeProvider.AUDITORS);
- assertThat("Named rule items equality without order", actual.getNamedItems(), IsIterableContainingInAnyOrder.containsInAnyOrder(namedRuleItems.toArray()));
- assertThat(actual.getUniqueItems().size(), is(6));
- List<String> uniqueRuleItems = Arrays.asList(ShardingRuleNodeProvider.DEFAULT_DATABASE_STRATEGY, ShardingRuleNodeProvider.DEFAULT_TABLE_STRATEGY,
- ShardingRuleNodeProvider.DEFAULT_KEY_GENERATE_STRATEGY, ShardingRuleNodeProvider.DEFAULT_AUDIT_STRATEGY, ShardingRuleNodeProvider.DEFAULT_SHARDING_COLUMN,
- ShardingRuleNodeProvider.SHARDING_CACHE);
- assertThat("Unique rule items equality without order", actual.getUniqueItems(), IsIterableContainingInAnyOrder.containsInAnyOrder(uniqueRuleItems.toArray()));
- assertThat(actual.getRuleType(), is(ShardingRuleNodeProvider.RULE_TYPE));
- }
-}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProvider.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProvider.java
deleted file mode 100644
index 95dc08c6bf3..00000000000
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.single.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Single rule node provider.
- */
-public final class SingleRuleNodeProvider implements DatabaseRuleNodeProvider {
-
- public static final String RULE_TYPE = "single";
-
- public static final String TABLES = "tables";
-
- public static final String DEFAULT_DATA_SOURCE = "default_data_source";
-
- private static final DatabaseRuleNode INSTANCE = new DatabaseRuleNode(RULE_TYPE, Collections.emptyList(), Arrays.asList(TABLES, DEFAULT_DATA_SOURCE));
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- return INSTANCE;
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return SingleRuleConfiguration.class;
- }
-}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/DefaultDataSourceChangedProcessor.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/DefaultDataSourceChangedProcessor.java
index f432c7c2414..9f697b6e9f0 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/DefaultDataSourceChangedProcessor.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/DefaultDataSourceChangedProcessor.java
@@ -18,11 +18,10 @@
package org.apache.shardingsphere.single.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
-import org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodeProvider;
import org.apache.shardingsphere.single.rule.SingleRule;
/**
@@ -52,6 +51,6 @@ public final class DefaultDataSourceChangedProcessor implements RuleItemConfigur
@Override
public String getType() {
- return SingleRuleNodeProvider.RULE_TYPE + "." + SingleRuleNodeProvider.DEFAULT_DATA_SOURCE;
+ return "single.default_data_source";
}
}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/SingleTableChangedProcessor.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/SingleTableChangedProcessor.java
index f23dcd13386..506928f9ed3 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/SingleTableChangedProcessor.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/changed/SingleTableChangedProcessor.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.single.rule.changed;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.mode.spi.rule.item.alter.AlterRuleItem;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropRuleItem;
-import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
-import org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodeProvider;
import org.apache.shardingsphere.single.rule.SingleRule;
import java.util.LinkedHashSet;
@@ -57,6 +56,6 @@ public final class SingleTableChangedProcessor implements RuleItemConfigurationC
@Override
public String getType() {
- return SingleRuleNodeProvider.RULE_TYPE + "." + SingleRuleNodeProvider.TABLES;
+ return "single.tables";
}
}
diff --git a/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 23b7fafa1a7..00000000000
--- a/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodeProvider
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProviderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProviderTest.java
deleted file mode 100644
index 75246a343ff..00000000000
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/metadata/nodepath/SingleRuleNodeProviderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.single.metadata.nodepath;
-
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class SingleRuleNodeProviderTest {
-
- private final DatabaseRuleNodeProvider provider = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, SingleRuleConfiguration.class);
-
- @Test
- void assertGetDatabaseRuleNode() {
- DatabaseRuleNode actual = provider.getDatabaseRuleNode();
- assertTrue(actual.getNamedItems().isEmpty());
- assertThat(actual.getUniqueItems().size(), is(2));
- assertTrue(actual.getUniqueItems().contains(SingleRuleNodeProvider.TABLES));
- assertTrue(actual.getUniqueItems().contains(SingleRuleNodeProvider.DEFAULT_DATA_SOURCE));
- assertThat(actual.getRuleType(), is(SingleRuleNodeProvider.RULE_TYPE));
- }
-}
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 1d9ec74c336..fe8bd1af374 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
@@ -18,12 +18,17 @@
package org.apache.shardingsphere.mode.metadata.changed;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.metadata.changed.executor.RuleItemChangedBuildExecutor;
import org.apache.shardingsphere.mode.node.path.engine.searcher.NodePathSearcher;
import org.apache.shardingsphere.mode.node.path.type.metadata.rule.DatabaseRuleNodePath;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
+import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeGenerator;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleEntity;
import org.apache.shardingsphere.mode.spi.rule.item.RuleChangedItem;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
import java.util.Optional;
/**
@@ -42,13 +47,33 @@ public final class RuleItemChangedBuilder {
* @return built rule item
*/
public <T extends RuleChangedItem> Optional<T> build(final String databaseName, final String path, final Integer activeVersion, final RuleItemChangedBuildExecutor<T> executor) {
- for (DatabaseRuleNodeProvider each : ShardingSphereServiceLoader.getServiceInstances(DatabaseRuleNodeProvider.class)) {
- if (!NodePathSearcher.isMatchedPath(path, DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(each.getDatabaseRuleNode().getRuleType()))) {
+ Optional<String> ruleType = NodePathSearcher.find(path, DatabaseRuleNodePath.createRuleTypeSearchCriteria());
+ if (!ruleType.isPresent()) {
+ return Optional.empty();
+ }
+ Optional<Class<? extends YamlRuleConfiguration>> yamlRuleConfigurationClass = findYamlRuleConfigurationClass(ruleType.get());
+ return yamlRuleConfigurationClass.isPresent() ? executor.build(DatabaseRuleNodeGenerator.generate(yamlRuleConfigurationClass.get()), databaseName, path, activeVersion) : Optional.empty();
+ }
+
+ private Optional<Class<? extends YamlRuleConfiguration>> findYamlRuleConfigurationClass(final String ruleType) {
+ for (YamlRuleConfigurationSwapper<?, ?> each : ShardingSphereServiceLoader.getServiceInstances(YamlRuleConfigurationSwapper.class)) {
+ Optional<Class<? extends YamlRuleConfiguration>> yamlRuleConfigurationClass = findYamlRuleConfigurationClass(each.getClass());
+ if (!yamlRuleConfigurationClass.isPresent()) {
continue;
}
- Optional<T> result = executor.build(each.getDatabaseRuleNode(), databaseName, path, activeVersion);
- if (result.isPresent()) {
- return result;
+ RuleRepositoryTupleEntity entity = yamlRuleConfigurationClass.get().getAnnotation(RuleRepositoryTupleEntity.class);
+ if (null != entity && entity.value().equals(ruleType)) {
+ return yamlRuleConfigurationClass;
+ }
+ }
+ return Optional.empty();
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private Optional<Class<? extends YamlRuleConfiguration>> findYamlRuleConfigurationClass(final Class<? extends YamlRuleConfigurationSwapper> swapperClass) {
+ for (Type each : swapperClass.getGenericInterfaces()) {
+ if (each instanceof ParameterizedType) {
+ return Optional.of((Class<? extends YamlRuleConfiguration>) ((ParameterizedType) each).getActualTypeArguments()[0]);
}
}
return Optional.empty();
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePath.java
index 0973c34f29c..30213b88eb9 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/type/metadata/rule/DatabaseRuleNodePath.java
@@ -48,6 +48,15 @@ public final class DatabaseRuleNodePath implements NodePath {
return new NodePathSearchCriteria(new DatabaseRuleNodePath(NodePathPattern.IDENTIFIER, ruleType, null), false, true, 1);
}
+ /**
+ * Create rule type search criteria.
+ *
+ * @return create search criteria
+ */
+ public static NodePathSearchCriteria createRuleTypeSearchCriteria() {
+ return new NodePathSearchCriteria(new DatabaseRuleNodePath(NodePathPattern.IDENTIFIER, NodePathPattern.IDENTIFIER, null), false, true, 2);
+ }
+
/**
* Create rule item name search criteria.
*
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeGenerator.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeGenerator.java
new file mode 100644
index 00000000000..96e7fd69049
--- /dev/null
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeGenerator.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mode.node.rule.node;
+
+import com.google.common.base.CaseFormat;
+import com.google.common.base.Preconditions;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleEntity;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleField;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleKeyListNameGenerator;
+
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Database rule node generator.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DatabaseRuleNodeGenerator {
+
+ /**
+ * Generate database rule node.
+ *
+ * @param yamlRuleConfigurationClass YAML rule configuration class
+ * @return generated database rule node
+ */
+ public static DatabaseRuleNode generate(final Class<? extends YamlRuleConfiguration> yamlRuleConfigurationClass) {
+ RuleRepositoryTupleEntity tupleEntity = yamlRuleConfigurationClass.getAnnotation(RuleRepositoryTupleEntity.class);
+ Preconditions.checkNotNull(tupleEntity, "Can not find @RuleRepositoryTupleEntity on class: ", yamlRuleConfigurationClass.getName());
+ Collection<String> namedItems = new LinkedList<>();
+ Collection<String> uniqueItems = new LinkedList<>();
+ for (Field each : getFields(yamlRuleConfigurationClass)) {
+ if (null == each.getAnnotation(RuleRepositoryTupleField.class)) {
+ continue;
+ }
+ if (each.getType().equals(Map.class) || each.getType().equals(Collection.class) && null != each.getAnnotation(RuleRepositoryTupleKeyListNameGenerator.class)) {
+ namedItems.add(getPersistTupleName(each));
+ } else {
+ uniqueItems.add(getPersistTupleName(each));
+ }
+ }
+ return new DatabaseRuleNode(tupleEntity.value(), namedItems, uniqueItems);
+ }
+
+ private static Collection<Field> getFields(final Class<? extends YamlRuleConfiguration> yamlRuleConfigurationClass) {
+ return Arrays.stream(yamlRuleConfigurationClass.getDeclaredFields())
+ .filter(each -> null != each.getAnnotation(RuleRepositoryTupleField.class))
+ .sorted(Comparator.comparingInt(o -> o.getAnnotation(RuleRepositoryTupleField.class).type().ordinal())).collect(Collectors.toList());
+ }
+
+ private static String getPersistTupleName(final Field field) {
+ return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, field.getName());
+ }
+}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeProvider.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeProvider.java
deleted file mode 100644
index da271cbeb79..00000000000
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/node/DatabaseRuleNodeProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.rule.node;
-
-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;
-
-/**
- * Database rule node provider.
- */
-@SingletonSPI
-public interface DatabaseRuleNodeProvider extends TypedSPI {
-
- /**
- * Get database rule node.
- *
- * @return got database rule node
- */
- DatabaseRuleNode getDatabaseRuleNode();
-
- @Override
- Class<? extends RuleConfiguration> getType();
-}
diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleRepositoryTupleSwapperEngine.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleRepositoryTupleSwapperEngine.java
index 81ae6bdb1db..bec0bdd8405 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleRepositoryTupleSwapperEngine.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleRepositoryTupleSwapperEngine.java
@@ -22,7 +22,6 @@ import com.google.common.base.Strings;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
@@ -35,7 +34,7 @@ import org.apache.shardingsphere.mode.node.path.type.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.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
+import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeGenerator;
import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleEntity;
import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleField;
import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleKeyListNameGenerator;
@@ -159,7 +158,7 @@ public final class YamlRuleRepositoryTupleSwapperEngine {
return Optional.empty();
}
YamlRuleConfiguration yamlRuleConfig = toBeSwappedType.getConstructor().newInstance();
- DatabaseRuleNode databaseRuleNode = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNode();
+ DatabaseRuleNode databaseRuleNode = DatabaseRuleNodeGenerator.generate(yamlRuleConfig.getClass());
for (RuleRepositoryTuple each : tuples.stream()
.filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(databaseRuleNode.getRuleType()))).collect(Collectors.toList())) {
DatabaseRuleNodePath databaseRuleNodePath = new DatabaseRuleNodePath(NodePathPattern.IDENTIFIER, databaseRuleNode.getRuleType(), new DatabaseRuleItem(entity.value()));
@@ -174,7 +173,7 @@ public final class YamlRuleRepositoryTupleSwapperEngine {
private Optional<YamlRuleConfiguration> swapToYamlRuleConfiguration(final Collection<RuleRepositoryTuple> tuples,
final Class<? extends YamlRuleConfiguration> toBeSwappedType, final Collection<Field> fields) {
YamlRuleConfiguration yamlRuleConfig = toBeSwappedType.getConstructor().newInstance();
- DatabaseRuleNode databaseRuleNode = TypedSPILoader.getService(DatabaseRuleNodeProvider.class, yamlRuleConfig.getRuleConfigurationType()).getDatabaseRuleNode();
+ DatabaseRuleNode databaseRuleNode = DatabaseRuleNodeGenerator.generate(yamlRuleConfig.getClass());
List<RuleRepositoryTuple> validTuples = tuples.stream()
.filter(each -> NodePathSearcher.isMatchedPath(each.getKey(), DatabaseRuleNodePath.createValidRuleTypeSearchCriteria(databaseRuleNode.getRuleType()))).collect(Collectors.toList());
if (validTuples.isEmpty()) {
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/node/RuleNodeProviderFixture.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/node/RuleNodeProviderFixture.java
deleted file mode 100644
index b3f0522271e..00000000000
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/node/RuleNodeProviderFixture.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.node.rule.fixture.node;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
-
-import java.util.Arrays;
-
-public final class RuleNodeProviderFixture implements DatabaseRuleNodeProvider {
-
- @Override
- public DatabaseRuleNode getDatabaseRuleNode() {
- 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"));
- }
-
- @Override
- public Class<? extends RuleConfiguration> getType() {
- return RuleConfiguration.class;
- }
-}
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/none/NoneYamlRuleConfiguration.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/none/NoneYamlRuleConfiguration.java
index d12a6016e26..7a9832e127e 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/none/NoneYamlRuleConfiguration.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/fixture/none/NoneYamlRuleConfiguration.java
@@ -19,7 +19,9 @@ package org.apache.shardingsphere.mode.node.rule.fixture.none;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleEntity;
+@RuleRepositoryTupleEntity("none")
public final class NoneYamlRuleConfiguration implements YamlRuleConfiguration {
@Override
diff --git a/mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider b/mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
deleted file mode 100644
index 482cf263b1d..00000000000
--- a/mode/node/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.mode.node.rule.fixture.node.RuleNodeProviderFixture
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 9f193dd844d..6b60ceec56b 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
@@ -17,36 +17,27 @@
package org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.database.rule;
-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.rule.node.DatabaseRuleNode;
-import org.apache.shardingsphere.mode.node.rule.node.DatabaseRuleNodeProvider;
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;
import org.apache.shardingsphere.mode.spi.rule.item.drop.DropUniqueRuleItem;
-import org.apache.shardingsphere.test.mock.AutoMockExtension;
-import org.apache.shardingsphere.test.mock.StaticMockSettings;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
-import java.util.Collections;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-@ExtendWith(AutoMockExtension.class)
-@StaticMockSettings(ShardingSphereServiceLoader.class)
+@ExtendWith(MockitoExtension.class)
class RuleConfigurationChangedHandlerTest {
private RuleConfigurationChangedHandler handler;
@@ -57,9 +48,6 @@ class RuleConfigurationChangedHandlerTest {
@BeforeEach
void setUp() {
handler = new RuleConfigurationChangedHandler(contextManager);
- DatabaseRuleNodeProvider databaseRuleNodeProvider = mock(DatabaseRuleNodeProvider.class, RETURNS_DEEP_STUBS);
- when(databaseRuleNodeProvider.getDatabaseRuleNode()).thenReturn(new DatabaseRuleNode("foo_rule", Collections.singleton("named"), Collections.singleton("unique")));
- when(ShardingSphereServiceLoader.getServiceInstances(DatabaseRuleNodeProvider.class)).thenReturn(Collections.singleton(databaseRuleNodeProvider));
}
@Test
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/RuleConfigurationFixture.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/RuleConfigurationFixture.java
index 247f003fe75..21310fe1eea 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/RuleConfigurationFixture.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/RuleConfigurationFixture.java
@@ -22,9 +22,13 @@ import lombok.Setter;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.function.EnhancedRuleConfiguration;
+import java.util.Map;
+
@Getter
@Setter
public final class RuleConfigurationFixture implements RuleConfiguration, EnhancedRuleConfiguration {
- private String name;
+ private String unique;
+
+ private Map<String, String> named;
}
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationFixture.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationFixture.java
index 57ae1f5ebda..faa609da6ec 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationFixture.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationFixture.java
@@ -20,12 +20,22 @@ package org.apache.shardingsphere.mode.manager.cluster.fixture;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleEntity;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleField;
+import org.apache.shardingsphere.mode.node.rule.tuple.annotation.RuleRepositoryTupleField.Type;
+
+import java.util.Map;
@Getter
@Setter
+@RuleRepositoryTupleEntity("foo_rule")
public final class YamlRuleConfigurationFixture implements YamlRuleConfiguration {
- private String name;
+ @RuleRepositoryTupleField(type = Type.OTHER)
+ private String unique;
+
+ @RuleRepositoryTupleField(type = Type.OTHER)
+ private Map<String, String> named;
@Override
public Class<RuleConfigurationFixture> getRuleConfigurationType() {
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationSwapperFixture.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationSwapperFixture.java
index 1673c35dd82..42bd3a256aa 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationSwapperFixture.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -29,14 +29,16 @@ public final class YamlRuleConfigurationSwapperFixture implements YamlRuleConfig
@Override
public YamlRuleConfigurationFixture swapToYamlConfiguration(final RuleConfigurationFixture data) {
YamlRuleConfigurationFixture result = new YamlRuleConfigurationFixture();
- result.setName(data.getName());
+ result.setUnique(data.getUnique());
+ result.setNamed(data.getNamed());
return result;
}
@Override
public RuleConfigurationFixture swapToObject(final YamlRuleConfigurationFixture yamlConfig) {
RuleConfigurationFixture result = new RuleConfigurationFixture();
- result.setName(yamlConfig.getName());
+ result.setUnique(yamlConfig.getUnique());
+ result.setNamed(yamlConfig.getNamed());
return result;
}