You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2024/03/25 02:04:11 UTC

(shardingsphere) branch master updated: Remove ImportRuleConfigurationProvider (#30629)

This is an automated email from the ASF dual-hosted git repository.

chengzhang 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 e37cedbc6a2 Remove ImportRuleConfigurationProvider (#30629)
e37cedbc6a2 is described below

commit e37cedbc6a2c2e0f1032872b8757f62a369ff7a8
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Mar 25 10:04:05 2024 +0800

    Remove ImportRuleConfigurationProvider (#30629)
    
    * Refactor AlterEncryptRuleExecutorTest
    
    * Move ImportRuleConfigurationChecker
    
    * Move ImportRuleConfigurationChecker
    
    * Move ImportRuleConfigurationChecker
    
    * Merge EncryptRuleConfigurationChecker and EncryptImportRuleConfigurationProvider
    
    * Merge MaskRuleConfigurationChecker and MaskImportRuleConfigurationProvider
    
    * Merge ReadwriteSplittingRuleConfigurationChecker and ReadwriteSplittingImportRuleConfigurationProvider
    
    * Merge ShadowRuleConfigurationChecker and ShadowImportRuleConfigurationProvider
    
    * Merge ShardingRuleConfigurationChecker and ShardingImportRuleConfigurationProvider
    
    * Merge ShardingRuleConfigurationChecker and ShardingImportRuleConfigurationProvider
---
 .../checker/EncryptRuleConfigurationChecker.java   | 47 +++++++----
 .../EncryptRuleConfigurationCheckerTest.java       |  9 ++-
 .../EncryptImportRuleConfigurationProvider.java    | 77 ------------------
 .../handler/update/CreateEncryptRuleExecutor.java  |  2 +-
 ...le.spi.database.ImportRuleConfigurationProvider | 18 -----
 .../update/AlterEncryptRuleExecutorTest.java       |  3 +-
 .../mask/checker/MaskRuleConfigurationChecker.java | 21 ++++-
 .../MaskImportRuleConfigurationProvider.java       | 68 ----------------
 ...le.spi.database.ImportRuleConfigurationProvider | 18 -----
 ...ReadwriteSplittingRuleConfigurationChecker.java | 48 ++++++-----
 ...teSplittingImportRuleConfigurationProvider.java | 61 --------------
 ...le.spi.database.ImportRuleConfigurationProvider | 18 -----
 ...littingImportRuleConfigurationProviderTest.java | 81 -------------------
 .../checker/ShadowRuleConfigurationChecker.java    | 34 +++++++-
 .../ShadowRuleConfigurationCheckerTest.java        |  2 +-
 .../ShadowImportRuleConfigurationProvider.java     | 72 -----------------
 .../AlterDefaultShadowAlgorithmExecutor.java       |  4 +-
 .../handler/update/AlterShadowRuleExecutor.java    |  2 +-
 .../CreateDefaultShadowAlgorithmExecutor.java      |  4 +-
 .../update/DropDefaultShadowAlgorithmExecutor.java |  2 +-
 .../update/DropShadowAlgorithmExecutor.java        |  4 +-
 ...le.spi.database.ImportRuleConfigurationProvider | 18 -----
 .../AlterDefaultShadowAlgorithmExecutorTest.java   |  4 +-
 .../update/AlterShadowRuleExecutorTest.java        |  2 +-
 .../DropDefaultShadowAlgorithmExecutorTest.java    |  2 +-
 .../checker/ShardingRuleConfigurationChecker.java  | 49 ++++++++++++
 .../ShardingRuleConfigurationCheckerTest.java      | 11 ++-
 .../checker/ShardingTableRuleStatementChecker.java |  2 +-
 .../ShardingImportRuleConfigurationProvider.java   | 90 ---------------------
 .../AlterDefaultShardingStrategyExecutor.java      |  4 +-
 .../CreateDefaultShardingStrategyExecutor.java     |  4 +-
 .../update/DropShardingAlgorithmExecutor.java      |  4 +-
 .../update/DropShardingAuditorExecutor.java        |  4 +-
 .../update/DropShardingKeyGeneratorExecutor.java   |  4 +-
 ...le.spi.database.ImportRuleConfigurationProvider | 18 -----
 .../checker/ShardingRuleStatementCheckerTest.java  |  2 +-
 ...hardingImportRuleConfigurationProviderTest.java | 93 ----------------------
 .../AlterDefaultShardingStrategyExecutorTest.java  |  4 +-
 .../CreateDefaultShardingStrategyExecutorTest.java |  4 +-
 .../CreateShardingTableRuleExecutorTest.java       |  4 +-
 .../update/DropShardingAlgorithmExecutorTest.java  |  4 +-
 .../update/DropShardingAuditorExecutorTest.java    |  4 +-
 .../DropShardingKeyGeneratorExecutorTest.java      |  4 +-
 .../checker/RuleConfigurationCheckEngine.java}     | 28 ++++---
 .../rule/checker/RuleConfigurationChecker.java     | 11 +++
 .../algorithm/AlgorithmInUsedException.java        |  5 +-
 .../algorithm/DuplicateAlgorithmException.java     |  5 +-
 .../InvalidAlgorithmConfigurationException.java    |  5 +-
 .../MissingRequiredAlgorithmException.java         |  5 +-
 .../database/ImportRuleConfigurationProvider.java  | 55 -------------
 .../category/AlgorithmDefinitionException.java}    | 16 ++--
 .../distsql/ral/updatable/LockClusterExecutor.java |  2 +-
 .../YamlDatabaseConfigurationImportExecutor.java   |  4 +-
 53 files changed, 259 insertions(+), 807 deletions(-)

diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
index c66135ebe91..4ea6481d65c 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
@@ -28,14 +28,19 @@ import org.apache.shardingsphere.encrypt.exception.metadata.EncryptCipherColumnN
 import org.apache.shardingsphere.encrypt.exception.metadata.EncryptLikeQueryColumnNotFoundException;
 import org.apache.shardingsphere.encrypt.exception.metadata.MissingEncryptorException;
 import org.apache.shardingsphere.encrypt.exception.metadata.UnregisteredEncryptorException;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 
 import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * Encrypt rule configuration checker.
@@ -44,41 +49,51 @@ public final class EncryptRuleConfigurationChecker implements RuleConfigurationC
     
     @Override
     public void check(final String databaseName, final EncryptRuleConfiguration ruleConfig, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules) {
-        checkTableConfiguration(databaseName, ruleConfig.getTables(), ruleConfig.getEncryptors());
+        checkEncryptors(ruleConfig.getEncryptors());
+        checkTables(databaseName, ruleConfig.getTables(), ruleConfig.getEncryptors());
     }
     
-    private void checkTableConfiguration(final String databaseName, final Collection<EncryptTableRuleConfiguration> tableRuleConfigs, final Map<String, AlgorithmConfiguration> encryptors) {
-        for (EncryptTableRuleConfiguration each : tableRuleConfigs) {
-            checkColumnConfiguration(databaseName, each, encryptors);
-        }
+    private void checkEncryptors(final Map<String, AlgorithmConfiguration> encryptors) {
+        encryptors.values().forEach(each -> TypedSPILoader.checkService(EncryptAlgorithm.class, each.getType(), each.getProps()));
+    }
+    
+    private void checkTables(final String databaseName, final Collection<EncryptTableRuleConfiguration> tableRuleConfigs, final Map<String, AlgorithmConfiguration> encryptors) {
+        checkTablesNotDuplicated(databaseName, tableRuleConfigs);
+        tableRuleConfigs.forEach(each -> checkColumns(databaseName, each, encryptors));
+    }
+    
+    private void checkTablesNotDuplicated(final String databaseName, final Collection<EncryptTableRuleConfiguration> tableRuleConfigs) {
+        Collection<String> duplicatedTables = tableRuleConfigs.stream().map(EncryptTableRuleConfiguration::getName)
+                .collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream().filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("ENCRYPT", databaseName, duplicatedTables));
     }
     
-    private void checkColumnConfiguration(final String databaseName, final EncryptTableRuleConfiguration tableRuleConfig, final Map<String, AlgorithmConfiguration> encryptors) {
+    private void checkColumns(final String databaseName, final EncryptTableRuleConfiguration tableRuleConfig, final Map<String, AlgorithmConfiguration> encryptors) {
         for (EncryptColumnRuleConfiguration each : tableRuleConfig.getColumns()) {
-            checkCipherColumnConfiguration(databaseName, tableRuleConfig.getName(), each.getName(), each.getCipher(), encryptors);
-            each.getAssistedQuery().ifPresent(optional -> checkAssistColumnConfiguration(databaseName, tableRuleConfig.getName(), each.getName(), optional, encryptors));
-            each.getLikeQuery().ifPresent(optional -> checkLikeColumnConfiguration(databaseName, tableRuleConfig.getName(), each.getName(), optional, encryptors));
+            checkCipherColumn(databaseName, tableRuleConfig.getName(), each.getName(), each.getCipher(), encryptors);
+            each.getAssistedQuery().ifPresent(optional -> checkAssistColumn(databaseName, tableRuleConfig.getName(), each.getName(), optional, encryptors));
+            each.getLikeQuery().ifPresent(optional -> checkLikeColumn(databaseName, tableRuleConfig.getName(), each.getName(), optional, encryptors));
         }
     }
     
-    private void checkCipherColumnConfiguration(final String databaseName, final String tableName, final String logicColumnName,
-                                                final EncryptColumnItemRuleConfiguration cipherColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
+    private void checkCipherColumn(final String databaseName, final String tableName, final String logicColumnName,
+                                   final EncryptColumnItemRuleConfiguration cipherColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getName()), () -> new EncryptCipherColumnNotFoundException(logicColumnName, databaseName));
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getEncryptorName()), () -> new MissingEncryptorException(tableName, logicColumnName, "STANDARD"));
         ShardingSpherePreconditions.checkState(encryptors.containsKey(cipherColumnConfig.getEncryptorName()),
                 () -> new UnregisteredEncryptorException(databaseName, cipherColumnConfig.getEncryptorName()));
     }
     
-    private void checkAssistColumnConfiguration(final String databaseName, final String tableName, final String logicColumnName,
-                                                final EncryptColumnItemRuleConfiguration assistedQueryColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
+    private void checkAssistColumn(final String databaseName, final String tableName, final String logicColumnName,
+                                   final EncryptColumnItemRuleConfiguration assistedQueryColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getName()), () -> new EncryptAssistedQueryColumnNotFoundException(logicColumnName, databaseName));
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getEncryptorName()), () -> new MissingEncryptorException(tableName, logicColumnName, "ASSIST_QUERY"));
         ShardingSpherePreconditions.checkState(
                 encryptors.containsKey(assistedQueryColumnConfig.getEncryptorName()), () -> new UnregisteredEncryptorException(databaseName, assistedQueryColumnConfig.getEncryptorName()));
     }
     
-    private void checkLikeColumnConfiguration(final String databaseName, final String tableName, final String logicColumnName,
-                                              final EncryptColumnItemRuleConfiguration likeQueryColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
+    private void checkLikeColumn(final String databaseName, final String tableName, final String logicColumnName,
+                                 final EncryptColumnItemRuleConfiguration likeQueryColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getName()), () -> new EncryptLikeQueryColumnNotFoundException(logicColumnName, databaseName));
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getEncryptorName()), () -> new MissingEncryptorException(tableName, logicColumnName, "LIKE_QUERY"));
         ShardingSpherePreconditions.checkState(encryptors.containsKey(likeQueryColumnConfig.getEncryptorName()),
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
index e6814d40c8f..0075f3ae01c 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Properties;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.mock;
@@ -39,14 +40,14 @@ class EncryptRuleConfigurationCheckerTest {
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     void assertCheckWhenConfigValidConfiguration() {
-        EncryptRuleConfiguration config = createValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPILoader.getServicesByClass(RuleConfigurationChecker.class, Collections.singleton(config.getClass())).get(config.getClass());
-        checker.check("test", config, Collections.emptyMap(), Collections.emptyList());
+        EncryptRuleConfiguration ruleConfig = createValidConfiguration();
+        RuleConfigurationChecker checker = OrderedSPILoader.getServicesByClass(RuleConfigurationChecker.class, Collections.singleton(ruleConfig.getClass())).get(ruleConfig.getClass());
+        checker.check("test", ruleConfig, Collections.emptyMap(), Collections.emptyList());
     }
     
     private EncryptRuleConfiguration createValidConfiguration() {
         EncryptRuleConfiguration result = mock(EncryptRuleConfiguration.class);
-        when(result.getEncryptors()).thenReturn(Collections.singletonMap("aes_encryptor", mock(AlgorithmConfiguration.class)));
+        when(result.getEncryptors()).thenReturn(Collections.singletonMap("aes_encryptor", new AlgorithmConfiguration("MD5", new Properties())));
         EncryptColumnRuleConfiguration columnRuleConfig = new EncryptColumnRuleConfiguration("user_id", new EncryptColumnItemRuleConfiguration("user_cipher", "aes_encryptor"));
         Collection<EncryptColumnRuleConfiguration> columns = Collections.singleton(columnRuleConfig);
         when(result.getTables()).thenReturn(Collections.singleton(new EncryptTableRuleConfiguration("t_encrypt", columns)));
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptImportRuleConfigurationProvider.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptImportRuleConfigurationProvider.java
deleted file mode 100644
index eca437af360..00000000000
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptImportRuleConfigurationProvider.java
+++ /dev/null
@@ -1,77 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * Encrypt import rule configuration provider.
- */
-public final class EncryptImportRuleConfigurationProvider implements ImportRuleConfigurationProvider<EncryptRuleConfiguration> {
-    
-    @Override
-    public void check(final String databaseName, final EncryptRuleConfiguration ruleConfig) {
-        checkTables(databaseName, ruleConfig);
-        checkEncryptors(ruleConfig);
-        checkTableEncryptorsExisted(databaseName, ruleConfig);
-    }
-    
-    private void checkTables(final String databaseName, final EncryptRuleConfiguration ruleConfig) {
-        Collection<String> tableNames = ruleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
-        Collection<String> duplicatedTables = tableNames.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
-                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
-        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("ENCRYPT", databaseName, duplicatedTables));
-    }
-    
-    private void checkEncryptors(final EncryptRuleConfiguration ruleConfig) {
-        ruleConfig.getEncryptors().values().forEach(each -> TypedSPILoader.checkService(EncryptAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    private void checkTableEncryptorsExisted(final String databaseName, final EncryptRuleConfiguration ruleConfig) {
-        Collection<EncryptColumnRuleConfiguration> columns = new LinkedList<>();
-        ruleConfig.getTables().forEach(each -> columns.addAll(each.getColumns()));
-        Collection<String> notExistedEncryptors = columns.stream().map(optional -> optional.getCipher().getEncryptorName()).collect(Collectors.toList());
-        notExistedEncryptors.addAll(
-                columns.stream().map(optional -> optional.getLikeQuery().map(EncryptColumnItemRuleConfiguration::getEncryptorName).orElse(null)).filter(Objects::nonNull).collect(Collectors.toList()));
-        notExistedEncryptors.addAll(columns.stream().map(optional -> optional.getAssistedQuery().map(EncryptColumnItemRuleConfiguration::getEncryptorName).orElse(null)).filter(Objects::nonNull)
-                .collect(Collectors.toList()));
-        Collection<String> encryptors = ruleConfig.getEncryptors().keySet();
-        notExistedEncryptors.removeIf(encryptors::contains);
-        ShardingSpherePreconditions.checkState(notExistedEncryptors.isEmpty(), () -> new MissingRequiredAlgorithmException(databaseName, notExistedEncryptors));
-    }
-    
-    @Override
-    public Class<EncryptRuleConfiguration> getType() {
-        return EncryptRuleConfiguration.class;
-    }
-}
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
index c100b997b55..caed06aaa23 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.encrypt.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.exception.rule.InvalidRuleConfigurationException;
 import org.apache.shardingsphere.infra.exception.storageunit.EmptyStorageUnitException;
diff --git a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
deleted file mode 100644
index 544470758ce..00000000000
--- a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
+++ /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.distsql.handler.provider.EncryptImportRuleConfigurationProvider
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
index fa1553ae422..fe77f4a7cf8 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
@@ -62,8 +62,7 @@ class AlterEncryptRuleExecutorTest {
         EncryptRule rule = mock(EncryptRule.class);
         when(rule.getConfiguration()).thenReturn(new EncryptRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
         executor.setRule(rule);
-        assertThrows(MissingRequiredRuleException.class,
-                () -> executor.checkBeforeUpdate(createSQLStatement("MD5")));
+        assertThrows(MissingRequiredRuleException.class, () -> executor.checkBeforeUpdate(createSQLStatement("MD5")));
     }
     
     @Test
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
index 39ac6e928de..74add9d483e 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
@@ -21,15 +21,20 @@ import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfigurat
 import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmNotFoundOnColumnException;
 import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
 import org.apache.shardingsphere.mask.api.config.rule.MaskColumnRuleConfiguration;
 import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.constant.MaskOrder;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * Mask rule configuration checker.
@@ -38,13 +43,23 @@ public final class MaskRuleConfigurationChecker implements RuleConfigurationChec
     
     @Override
     public void check(final String databaseName, final MaskRuleConfiguration ruleConfig, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules) {
+        checkMaskAlgorithms(ruleConfig.getMaskAlgorithms());
         checkTables(databaseName, ruleConfig.getTables(), ruleConfig.getMaskAlgorithms());
     }
     
+    private void checkMaskAlgorithms(final Map<String, AlgorithmConfiguration> maskAlgorithms) {
+        maskAlgorithms.values().forEach(each -> TypedSPILoader.checkService(MaskAlgorithm.class, each.getType(), each.getProps()));
+    }
+    
     private void checkTables(final String databaseName, final Collection<MaskTableRuleConfiguration> tables, final Map<String, AlgorithmConfiguration> maskAlgorithms) {
-        for (MaskTableRuleConfiguration each : tables) {
-            checkColumns(databaseName, each.getName(), each.getColumns(), maskAlgorithms);
-        }
+        checkTablesNotDuplicated(databaseName, tables);
+        tables.forEach(each -> checkColumns(databaseName, each.getName(), each.getColumns(), maskAlgorithms));
+    }
+    
+    private void checkTablesNotDuplicated(final String databaseName, final Collection<MaskTableRuleConfiguration> tables) {
+        Collection<String> duplicatedTables = tables.stream().map(MaskTableRuleConfiguration::getName)
+                .collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream().filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("MASK", databaseName, duplicatedTables));
     }
     
     private void checkColumns(final String databaseName, final String tableName, final Collection<MaskColumnRuleConfiguration> columns, final Map<String, AlgorithmConfiguration> maskAlgorithms) {
diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskImportRuleConfigurationProvider.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskImportRuleConfigurationProvider.java
deleted file mode 100644
index 2255d033a64..00000000000
--- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskImportRuleConfigurationProvider.java
+++ /dev/null
@@ -1,68 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mask.api.config.rule.MaskColumnRuleConfiguration;
-import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
-import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
-
-import java.util.Collection;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-/**
- * Mask import rule configuration provider.
- */
-public final class MaskImportRuleConfigurationProvider implements ImportRuleConfigurationProvider<MaskRuleConfiguration> {
-    
-    @Override
-    public void check(final String databaseName, final MaskRuleConfiguration ruleConfig) {
-        checkTables(databaseName, ruleConfig);
-        checkMaskAlgorithms(ruleConfig);
-        checkMaskAlgorithmsExisted(databaseName, ruleConfig);
-    }
-    
-    private void checkTables(final String databaseName, final MaskRuleConfiguration ruleConfig) {
-        Collection<String> tableNames = ruleConfig.getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList());
-        Collection<String> duplicatedTables = tableNames.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
-                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
-        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("MASK", databaseName, duplicatedTables));
-    }
-    
-    private void checkMaskAlgorithms(final MaskRuleConfiguration ruleConfig) {
-        ruleConfig.getMaskAlgorithms().values().forEach(each -> TypedSPILoader.checkService(MaskAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    private void checkMaskAlgorithmsExisted(final String databaseName, final MaskRuleConfiguration ruleConfig) {
-        Collection<String> notExistedAlgorithms = ruleConfig.getTables().stream()
-                .flatMap(each -> each.getColumns().stream()).map(MaskColumnRuleConfiguration::getMaskAlgorithm).collect(Collectors.toList());
-        notExistedAlgorithms.removeIf(ruleConfig.getMaskAlgorithms().keySet()::contains);
-        ShardingSpherePreconditions.checkState(notExistedAlgorithms.isEmpty(), () -> new MissingRequiredAlgorithmException(databaseName, notExistedAlgorithms));
-    }
-    
-    @Override
-    public Class<MaskRuleConfiguration> getType() {
-        return MaskRuleConfiguration.class;
-    }
-}
diff --git a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
deleted file mode 100644
index 04b5da428c0..00000000000
--- a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
+++ /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.distsql.handler.provider.MaskImportRuleConfigurationProvider
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
index f6bc2cb4f94..8bb5bd43f9e 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
@@ -38,9 +38,10 @@ import org.apache.shardingsphere.readwritesplitting.exception.checker.MissingReq
 import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
-import java.util.Optional;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * Readwrite-splitting rule configuration checker.
@@ -51,7 +52,7 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
     public void check(final String databaseName, final ReadwriteSplittingRuleConfiguration ruleConfig, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules) {
         Collection<ReadwriteSplittingDataSourceRuleConfiguration> configs = ruleConfig.getDataSources();
         checkDataSources(databaseName, configs, dataSourceMap, builtRules);
-        checkLoadBalancer(databaseName, configs, getLoadBalancer(ruleConfig));
+        checkLoadBalancer(databaseName, ruleConfig);
     }
     
     private void checkDataSources(final String databaseName, final Collection<ReadwriteSplittingDataSourceRuleConfiguration> configs,
@@ -66,33 +67,28 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
     
     private void checkDataSources(final String databaseName, final Map<String, DataSource> dataSourceMap,
                                   final ReadwriteSplittingDataSourceRuleConfiguration config, final Collection<String> addedWriteDataSourceNames,
-                                  final Collection<String> readDataSourceNames, final Collection<ShardingSphereRule> rules) {
+                                  final Collection<String> readDataSourceNames, final Collection<ShardingSphereRule> builtRules) {
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(config.getWriteDataSourceName()), () -> new MissingRequiredWriteDataSourceNameException(databaseName));
         ShardingSpherePreconditions.checkState(!config.getReadDataSourceNames().isEmpty(), () -> new MissingRequiredReadDataSourceNamesException(databaseName));
-        checkWriteDataSourceNames(databaseName, dataSourceMap, addedWriteDataSourceNames, config, rules);
+        checkWriteDataSourceNames(databaseName, dataSourceMap, addedWriteDataSourceNames, config, builtRules);
         for (String each : config.getReadDataSourceNames()) {
-            checkReadeDataSourceNames(databaseName, dataSourceMap, readDataSourceNames, each, rules);
+            checkReadeDataSourceNames(databaseName, dataSourceMap, readDataSourceNames, each, builtRules);
         }
     }
     
     private void checkWriteDataSourceNames(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<String> addedWriteDataSourceNames,
-                                           final ReadwriteSplittingDataSourceRuleConfiguration config, final Collection<ShardingSphereRule> rules) {
+                                           final ReadwriteSplittingDataSourceRuleConfiguration config, final Collection<ShardingSphereRule> builtRules) {
         for (String each : InlineExpressionParserFactory.newInstance(config.getWriteDataSourceName()).splitAndEvaluate()) {
-            ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each) || containsInOtherRules(each, rules),
+            ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each) || containsInOtherRules(each, builtRules),
                     () -> new DataSourceNameNotExistedException(String.format("Write data source name `%s` not in database `%s`.", each, databaseName)));
             ShardingSpherePreconditions.checkState(addedWriteDataSourceNames.add(each),
                     () -> new DuplicateDataSourceException(String.format("Can not config duplicate write data source `%s` in database `%s`.", each, databaseName)));
         }
     }
     
-    private boolean containsInOtherRules(final String datasourceName, final Collection<ShardingSphereRule> rules) {
-        for (ShardingSphereRule each : rules) {
-            Optional<DataSourceMapperRuleAttribute> ruleAttribute = each.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class);
-            if (ruleAttribute.isPresent() && ruleAttribute.get().getDataSourceMapper().containsKey(datasourceName)) {
-                return true;
-            }
-        }
-        return false;
+    private boolean containsInOtherRules(final String datasourceName, final Collection<ShardingSphereRule> builtRules) {
+        return builtRules.stream().map(each -> each.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class))
+                .anyMatch(ruleAttribute -> ruleAttribute.isPresent() && ruleAttribute.get().getDataSourceMapper().containsKey(datasourceName));
     }
     
     private void checkReadeDataSourceNames(final String databaseName, final Map<String, DataSource> dataSourceMap,
@@ -105,8 +101,10 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
         }
     }
     
-    private void checkLoadBalancer(final String databaseName, final Collection<ReadwriteSplittingDataSourceRuleConfiguration> configs, final Map<String, LoadBalanceAlgorithm> loadBalancers) {
-        for (ReadwriteSplittingDataSourceRuleConfiguration each : configs) {
+    private void checkLoadBalancer(final String databaseName, final ReadwriteSplittingRuleConfiguration ruleConfig) {
+        Map<String, LoadBalanceAlgorithm> loadBalancers = ruleConfig.getLoadBalancers().entrySet().stream()
+                .collect(Collectors.toMap(Entry::getKey, entry -> TypedSPILoader.getService(LoadBalanceAlgorithm.class, entry.getValue().getType(), entry.getValue().getProps())));
+        for (ReadwriteSplittingDataSourceRuleConfiguration each : ruleConfig.getDataSources()) {
             if (Strings.isNullOrEmpty(each.getLoadBalancerName())) {
                 continue;
             }
@@ -116,9 +114,17 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
         }
     }
     
-    private Map<String, LoadBalanceAlgorithm> getLoadBalancer(final ReadwriteSplittingRuleConfiguration ruleConfig) {
-        Map<String, LoadBalanceAlgorithm> result = new LinkedHashMap<>(ruleConfig.getLoadBalancers().size(), 1F);
-        ruleConfig.getLoadBalancers().forEach((key, value) -> result.put(key, TypedSPILoader.getService(LoadBalanceAlgorithm.class, value.getType(), value.getProps())));
+    @Override
+    public Collection<String> getRequiredDataSourceNames(final ReadwriteSplittingRuleConfiguration ruleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        for (ReadwriteSplittingDataSourceRuleConfiguration each : ruleConfig.getDataSources()) {
+            if (null != each.getWriteDataSourceName()) {
+                result.add(each.getWriteDataSourceName());
+            }
+            if (!each.getReadDataSourceNames().isEmpty()) {
+                result.addAll(each.getReadDataSourceNames());
+            }
+        }
         return result;
     }
     
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProvider.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProvider.java
deleted file mode 100644
index 5784003282c..00000000000
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProvider.java
+++ /dev/null
@@ -1,61 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider;
-import org.apache.shardingsphere.infra.algorithm.loadbalancer.core.LoadBalanceAlgorithm;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-
-/**
- * Readwrite-splitting import rule configuration provider.
- */
-public final class ReadwriteSplittingImportRuleConfigurationProvider implements ImportRuleConfigurationProvider<ReadwriteSplittingRuleConfiguration> {
-    
-    @Override
-    public void check(final String databaseName, final ReadwriteSplittingRuleConfiguration ruleConfig) {
-        checkLoadBalancers(ruleConfig);
-    }
-    
-    private void checkLoadBalancers(final ReadwriteSplittingRuleConfiguration ruleConfig) {
-        ruleConfig.getLoadBalancers().values().forEach(each -> TypedSPILoader.checkService(LoadBalanceAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    @Override
-    public Collection<String> getRequiredDataSourceNames(final ReadwriteSplittingRuleConfiguration ruleConfig) {
-        Collection<String> result = new LinkedHashSet<>();
-        for (ReadwriteSplittingDataSourceRuleConfiguration each : ruleConfig.getDataSources()) {
-            if (null != each.getWriteDataSourceName()) {
-                result.add(each.getWriteDataSourceName());
-            }
-            if (!each.getReadDataSourceNames().isEmpty()) {
-                result.addAll(each.getReadDataSourceNames());
-            }
-        }
-        return result;
-    }
-    
-    @Override
-    public Class<ReadwriteSplittingRuleConfiguration> getType() {
-        return ReadwriteSplittingRuleConfiguration.class;
-    }
-}
diff --git a/features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider b/features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
deleted file mode 100644
index 0ada7c83e45..00000000000
--- a/features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
+++ /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.distsql.handler.provider.ReadwriteSplittingImportRuleConfigurationProvider
diff --git a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProviderTest.java b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProviderTest.java
deleted file mode 100644
index 3ce43375f1d..00000000000
--- a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingImportRuleConfigurationProviderTest.java
+++ /dev/null
@@ -1,81 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationChecker;
-import org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
-import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-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.when;
-
-class ReadwriteSplittingImportRuleConfigurationProviderTest {
-    
-    private final ReadwriteSplittingImportRuleConfigurationProvider importRuleConfigProvider = new ReadwriteSplittingImportRuleConfigurationProvider();
-    
-    @Test
-    void assertCheckDataSources() {
-        ShardingSphereDatabase database = mockDatabaseWithDataSource();
-        ReadwriteSplittingRuleConfiguration currentRuleConfig = getRuleConfigWithNotExistedDataSources();
-        assertThrows(MissingRequiredStorageUnitsException.class, () -> ImportRuleConfigurationChecker.checkRule(currentRuleConfig, database));
-    }
-    
-    @Test
-    void assertCheckLoadBalancers() {
-        ReadwriteSplittingRuleConfiguration currentRuleConfig = createInvalidLoadBalancerRuleConfig();
-        assertThrows(ServiceProviderNotFoundException.class, () -> importRuleConfigProvider.check("foo_db", currentRuleConfig));
-    }
-    
-    private ShardingSphereDatabase mockDatabaseWithDataSource() {
-        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
-        Collection<String> dataSources = new LinkedList<>();
-        dataSources.add("su_1");
-        when(result.getRuleMetaData().getAttributes(DataSourceMapperRuleAttribute.class)).thenReturn(Collections.emptyList());
-        when(result.getResourceMetaData().getNotExistedDataSources(any())).thenReturn(dataSources);
-        return result;
-    }
-    
-    private ReadwriteSplittingRuleConfiguration getRuleConfigWithNotExistedDataSources() {
-        ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig =
-                new ReadwriteSplittingDataSourceRuleConfiguration("data_source", "write_ds", Collections.emptyList(), "load_balancer");
-        Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = new LinkedList<>();
-        dataSources.add(dataSourceRuleConfig);
-        return new ReadwriteSplittingRuleConfiguration(dataSources, Collections.emptyMap());
-    }
-    
-    private ReadwriteSplittingRuleConfiguration createInvalidLoadBalancerRuleConfig() {
-        Map<String, AlgorithmConfiguration> loadBalancer = new HashMap<>();
-        loadBalancer.put("invalid_load_balancer", mock(AlgorithmConfiguration.class));
-        return new ReadwriteSplittingRuleConfiguration(Collections.emptyList(), loadBalancer);
-    }
-}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
index 86bb0103fa6..ae58d08e91f 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
@@ -19,8 +19,10 @@ package org.apache.shardingsphere.shadow.checker;
 
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
@@ -29,13 +31,16 @@ import org.apache.shardingsphere.shadow.exception.algorithm.NotImplementHintShad
 import org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredShadowAlgorithmException;
 import org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredShadowConfigurationException;
 import org.apache.shardingsphere.shadow.exception.metadata.ShadowDataSourceMappingNotFoundException;
+import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
 
 import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * Shadow rule configuration checker.
@@ -44,6 +49,8 @@ public final class ShadowRuleConfigurationChecker implements RuleConfigurationCh
     
     @Override
     public void check(final String databaseName, final ShadowRuleConfiguration ruleConfig, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules) {
+        checkShadowAlgorithms(ruleConfig);
+        checkTablesNotDuplicated(databaseName, ruleConfig);
         Map<String, ShadowDataSourceConfiguration> dataSources = initShadowDataSources(ruleConfig.getDataSources());
         checkDataSources(dataSources, dataSourceMap, databaseName);
         Map<String, ShadowTableConfiguration> shadowTables = ruleConfig.getTables();
@@ -56,6 +63,17 @@ public final class ShadowRuleConfigurationChecker implements RuleConfigurationCh
         checkShadowTableAlgorithmsReferences(shadowTables, databaseName);
     }
     
+    private void checkShadowAlgorithms(final ShadowRuleConfiguration ruleConfig) {
+        ruleConfig.getShadowAlgorithms().values().forEach(each -> TypedSPILoader.checkService(ShadowAlgorithm.class, each.getType(), each.getProps()));
+    }
+    
+    private void checkTablesNotDuplicated(final String databaseName, final ShadowRuleConfiguration ruleConfig) {
+        Collection<String> tableNames = ruleConfig.getTables().keySet();
+        Collection<String> duplicatedTables = tableNames.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
+                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("SHADOW", databaseName, duplicatedTables));
+    }
+    
     private void checkDataSources(final Map<String, ShadowDataSourceConfiguration> shadowDataSources, final Map<String, DataSource> dataSourceMap, final String databaseName) {
         Set<String> dataSourceName = dataSourceMap.keySet();
         for (Entry<String, ShadowDataSourceConfiguration> entry : shadowDataSources.entrySet()) {
@@ -113,6 +131,20 @@ public final class ShadowRuleConfigurationChecker implements RuleConfigurationCh
         return result;
     }
     
+    @Override
+    public Collection<String> getRequiredDataSourceNames(final ShadowRuleConfiguration ruleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        ruleConfig.getDataSources().forEach(each -> {
+            if (null != each.getShadowDataSourceName()) {
+                result.add(each.getShadowDataSourceName());
+            }
+            if (null != each.getProductionDataSourceName()) {
+                result.add(each.getProductionDataSourceName());
+            }
+        });
+        return result;
+    }
+    
     @Override
     public int getOrder() {
         return ShadowOrder.ORDER;
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
index 0da4b74b984..2a0cc53bf2f 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
@@ -55,7 +55,7 @@ class ShadowRuleConfigurationCheckerTest {
     }
     
     private AlgorithmConfiguration createAlgorithmConfiguration() {
-        return new AlgorithmConfiguration("user-id-insert-match-algorithm",
+        return new AlgorithmConfiguration("REGEX_MATCH",
                 PropertiesBuilder.build(new Property("column", "shadow"), new Property("operation", "insert"), new Property("regex", "[1]")));
     }
 }
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/provider/ShadowImportRuleConfigurationProvider.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/provider/ShadowImportRuleConfigurationProvider.java
deleted file mode 100644
index 08813c47f87..00000000000
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/provider/ShadowImportRuleConfigurationProvider.java
+++ /dev/null
@@ -1,72 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
-import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-/**
- * Shadow import rule configuration provider.
- */
-public final class ShadowImportRuleConfigurationProvider implements ImportRuleConfigurationProvider<ShadowRuleConfiguration> {
-    
-    @Override
-    public void check(final String databaseName, final ShadowRuleConfiguration ruleConfig) {
-        checkTables(databaseName, ruleConfig);
-        checkShadowAlgorithms(ruleConfig);
-    }
-    
-    private void checkTables(final String databaseName, final ShadowRuleConfiguration ruleConfig) {
-        Collection<String> tableNames = ruleConfig.getTables().keySet();
-        Collection<String> duplicatedTables = tableNames.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
-                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
-        ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), () -> new DuplicateRuleException("SHADOW", databaseName, duplicatedTables));
-    }
-    
-    private void checkShadowAlgorithms(final ShadowRuleConfiguration ruleConfig) {
-        ruleConfig.getShadowAlgorithms().values().forEach(each -> TypedSPILoader.checkService(ShadowAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    @Override
-    public Collection<String> getRequiredDataSourceNames(final ShadowRuleConfiguration ruleConfig) {
-        Collection<String> result = new LinkedHashSet<>();
-        ruleConfig.getDataSources().forEach(each -> {
-            if (null != each.getShadowDataSourceName()) {
-                result.add(each.getShadowDataSourceName());
-            }
-            if (null != each.getProductionDataSourceName()) {
-                result.add(each.getProductionDataSourceName());
-            }
-        });
-        return result;
-    }
-    
-    @Override
-    public Class<ShadowRuleConfiguration> getType() {
-        return ShadowRuleConfiguration.class;
-    }
-}
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
index 4d830025ed5..294aaf605d3 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import com.google.common.base.Strings;
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
index f61104a247b..c2a0be24dc1 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
index f9df45b8b7b..4258c36a392 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.DuplicateAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.DuplicateAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
index 94618c8581e..6e7134be480 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
index b556047d1ca..37abdf7885c 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.KernelSQLException;
diff --git a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
deleted file mode 100644
index 0347c538e71..00000000000
--- a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
+++ /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.distsql.handler.provider.ShadowImportRuleConfigurationProvider
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmExecutorTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmExecutorTest.java
index 54fc6ce7373..a3539ba4e79 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmExecutorTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.shadow.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleExecutorTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleExecutorTest.java
index 51e7d50b9c8..1da05656697 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleExecutorTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleExecutorTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.shadow.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
 import org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmExecutorTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmExecutorTest.java
index d6fc548fcd4..8b2921aaa17 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmExecutorTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmExecutorTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.shadow.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationChecker.java
index 638872cfe4e..85033fb5b36 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationChecker.java
@@ -19,9 +19,15 @@ package org.apache.shardingsphere.sharding.checker;
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Strings;
+import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
 import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -33,10 +39,17 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingS
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import org.apache.shardingsphere.sharding.exception.metadata.MissingRequiredShardingAlgorithmException;
 import org.apache.shardingsphere.sharding.exception.metadata.MissingRequiredShardingConfigurationException;
+import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
 
 import javax.sql.DataSource;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * Sharding rule configuration checker.
@@ -45,6 +58,8 @@ public final class ShardingRuleConfigurationChecker implements RuleConfiguration
     
     @Override
     public void check(final String databaseName, final ShardingRuleConfiguration ruleConfig, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> builtRules) {
+        checkShardingAlgorithms(ruleConfig.getShardingAlgorithms().values());
+        checkKeyGeneratorAlgorithms(ruleConfig.getKeyGenerators().values());
         Collection<String> keyGenerators = ruleConfig.getKeyGenerators().keySet();
         Collection<String> auditors = ruleConfig.getAuditors().keySet();
         Collection<String> shardingAlgorithms = ruleConfig.getShardingAlgorithms().keySet();
@@ -55,8 +70,17 @@ public final class ShardingRuleConfigurationChecker implements RuleConfiguration
         checkShardingStrategy(databaseName, ruleConfig.getDefaultTableShardingStrategy(), shardingAlgorithms);
     }
     
+    private void checkShardingAlgorithms(final Collection<AlgorithmConfiguration> algorithmConfigs) {
+        algorithmConfigs.forEach(each -> TypedSPILoader.checkService(ShardingAlgorithm.class, each.getType(), each.getProps()));
+    }
+    
+    private void checkKeyGeneratorAlgorithms(final Collection<AlgorithmConfiguration> algorithmConfigs) {
+        algorithmConfigs.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(KeyGenerateAlgorithm.class, each.getType(), each.getProps()));
+    }
+    
     private void checkTableConfiguration(final String databaseName, final Collection<ShardingTableRuleConfiguration> tables, final Collection<ShardingAutoTableRuleConfiguration> autoTables,
                                          final Collection<String> keyGenerators, final Collection<String> auditors, final Collection<String> shardingAlgorithms) {
+        checkTablesNotDuplicated(databaseName, tables, autoTables);
         for (ShardingTableRuleConfiguration each : tables) {
             checkLogicTable(databaseName, each.getLogicTable());
             checkKeyGenerateStrategy(databaseName, each.getKeyGenerateStrategy(), keyGenerators);
@@ -72,6 +96,14 @@ public final class ShardingRuleConfigurationChecker implements RuleConfiguration
         }
     }
     
+    private void checkTablesNotDuplicated(final String databaseName, final Collection<ShardingTableRuleConfiguration> tables, final Collection<ShardingAutoTableRuleConfiguration> autoTables) {
+        Collection<String> logicTables = tables.stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toList());
+        logicTables.addAll(autoTables.stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toList()));
+        Set<String> duplicatedLogicTables = logicTables.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
+                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(duplicatedLogicTables.isEmpty(), () -> new DuplicateRuleException("sharding", databaseName, duplicatedLogicTables));
+    }
+    
     private void checkLogicTable(final String databaseName, final String logicTable) {
         ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(logicTable), () -> new MissingRequiredShardingConfigurationException("Sharding logic table", databaseName));
     }
@@ -106,6 +138,23 @@ public final class ShardingRuleConfigurationChecker implements RuleConfiguration
                 () -> new MissingRequiredShardingAlgorithmException(shardingStrategy.getShardingAlgorithmName(), databaseName));
     }
     
+    @Override
+    public Collection<String> getRequiredDataSourceNames(final ShardingRuleConfiguration ruleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        ruleConfig.getTables().forEach(each -> result.addAll(getDataSourceNames(each)));
+        ruleConfig.getAutoTables().forEach(each -> result.addAll(getDataSourceNames(each)));
+        return result;
+    }
+    
+    private Collection<String> getDataSourceNames(final ShardingTableRuleConfiguration shardingTableRuleConfig) {
+        Collection<String> actualDataNodes = InlineExpressionParserFactory.newInstance(shardingTableRuleConfig.getActualDataNodes()).splitAndEvaluate();
+        return actualDataNodes.stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
+    }
+    
+    private Collection<String> getDataSourceNames(final ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig) {
+        return new HashSet<>(InlineExpressionParserFactory.newInstance(shardingAutoTableRuleConfig.getActualDataSources()).splitAndEvaluate());
+    }
+    
     @Override
     public int getOrder() {
         return ShardingOrder.ORDER;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationCheckerTest.java
index 5a87b334a12..00aaf75fca9 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/ShardingRuleConfigurationCheckerTest.java
@@ -27,9 +27,12 @@ import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAudi
 import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import org.apache.shardingsphere.sharding.exception.metadata.MissingRequiredShardingConfigurationException;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
 import java.util.Collections;
+import java.util.Properties;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.mock;
@@ -63,9 +66,9 @@ class ShardingRuleConfigurationCheckerTest {
     
     private ShardingRuleConfiguration createRuleConfiguration() {
         ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.getShardingAlgorithms().put("foo_algorithm", mock(AlgorithmConfiguration.class));
-        result.getAuditors().put("foo_audit", mock(AlgorithmConfiguration.class));
-        result.getKeyGenerators().put("foo_keygen", mock(AlgorithmConfiguration.class));
+        result.getShardingAlgorithms().put("foo_algorithm", new AlgorithmConfiguration("MOD", PropertiesBuilder.build(new Property("sharding-count", "1"))));
+        result.getAuditors().put("foo_audit", new AlgorithmConfiguration("foo", new Properties()));
+        result.getKeyGenerators().put("foo_keygen", new AlgorithmConfiguration("UUID", new Properties()));
         result.setDefaultKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("foo_col", "foo_keygen"));
         return result;
     }
@@ -91,7 +94,7 @@ class ShardingRuleConfigurationCheckerTest {
                                                                                         final ShardingAuditStrategyConfiguration shardingAuditStrategyConfig,
                                                                                         final KeyGenerateStrategyConfiguration keyGenerateStrategyConfig) {
         ShardingAutoTableRuleConfiguration result = mock(ShardingAutoTableRuleConfiguration.class);
-        when(result.getLogicTable()).thenReturn("foo_tbl");
+        when(result.getLogicTable()).thenReturn("bar_tbl");
         when(result.getShardingStrategy()).thenReturn(null == shardingStrategyConfig ? mock(ShardingStrategyConfiguration.class) : shardingStrategyConfig);
         when(result.getAuditStrategy()).thenReturn(null == shardingAuditStrategyConfig ? mock(ShardingAuditStrategyConfiguration.class) : shardingAuditStrategyConfig);
         when(result.getKeyGenerateStrategy()).thenReturn(null == keyGenerateStrategyConfig ? mock(KeyGenerateStrategyConfiguration.class) : keyGenerateStrategyConfig);
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 41bef1f82ce..f6622464c60 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -21,7 +21,7 @@ import com.cedarsoftware.util.CaseInsensitiveSet;
 import com.google.common.base.Splitter;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.exception.rule.InvalidRuleConfigurationException;
 import org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/provider/ShardingImportRuleConfigurationProvider.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/provider/ShardingImportRuleConfigurationProvider.java
deleted file mode 100644
index 3734b54b810..00000000000
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/provider/ShardingImportRuleConfigurationProvider.java
+++ /dev/null
@@ -1,90 +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.distsql.handler.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Sharding import rule configuration provider.
- */
-public final class ShardingImportRuleConfigurationProvider implements ImportRuleConfigurationProvider<ShardingRuleConfiguration> {
-    
-    @Override
-    public void check(final String databaseName, final ShardingRuleConfiguration ruleConfig) {
-        checkLogicTables(databaseName, ruleConfig);
-        checkShardingAlgorithms(ruleConfig.getShardingAlgorithms().values());
-        checkKeyGeneratorAlgorithms(ruleConfig.getKeyGenerators().values());
-    }
-    
-    private void checkLogicTables(final String databaseName, final ShardingRuleConfiguration ruleConfig) {
-        Collection<String> logicTables = ruleConfig.getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toList());
-        logicTables.addAll(ruleConfig.getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toList()));
-        Set<String> duplicatedLogicTables = logicTables.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
-                .filter(each -> each.getValue() > 1).map(Entry::getKey).collect(Collectors.toSet());
-        ShardingSpherePreconditions.checkState(duplicatedLogicTables.isEmpty(), () -> new DuplicateRuleException("sharding", databaseName, duplicatedLogicTables));
-    }
-    
-    private void checkShardingAlgorithms(final Collection<AlgorithmConfiguration> algorithmConfigs) {
-        algorithmConfigs.forEach(each -> TypedSPILoader.checkService(ShardingAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    private void checkKeyGeneratorAlgorithms(final Collection<AlgorithmConfiguration> algorithmConfigs) {
-        algorithmConfigs.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(KeyGenerateAlgorithm.class, each.getType(), each.getProps()));
-    }
-    
-    @Override
-    public Collection<String> getRequiredDataSourceNames(final ShardingRuleConfiguration ruleConfig) {
-        Collection<String> result = new LinkedHashSet<>();
-        ruleConfig.getTables().forEach(each -> result.addAll(getDataSourceNames(each)));
-        ruleConfig.getAutoTables().forEach(each -> result.addAll(getDataSourceNames(each)));
-        return result;
-    }
-    
-    private Collection<String> getDataSourceNames(final ShardingTableRuleConfiguration shardingTableRuleConfig) {
-        Collection<String> actualDataNodes = InlineExpressionParserFactory.newInstance(shardingTableRuleConfig.getActualDataNodes()).splitAndEvaluate();
-        return actualDataNodes.stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
-    }
-    
-    private Collection<String> getDataSourceNames(final ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig) {
-        return new HashSet<>(InlineExpressionParserFactory.newInstance(shardingAutoTableRuleConfig.getActualDataSources()).splitAndEvaluate());
-    }
-    
-    @Override
-    public Class<ShardingRuleConfiguration> getType() {
-        return ShardingRuleConfiguration.class;
-    }
-}
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
index 1bcc8c7ae65..a49d3a2438b 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
index 1203ab80f4d..0ef6d8042b8 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
index d61cb16aeb2..dd008dd94f9 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
index 724ae459162..70357d24610 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
index 8e19b581dc0..1dd8a93da58 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import com.google.common.base.Strings;
 import lombok.Setter;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
deleted file mode 100644
index 896e8984273..00000000000
--- a/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationProvider
+++ /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.distsql.handler.provider.ShardingImportRuleConfigurationProvider
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 9b8381d6f1c..3e9aa131f70 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.sharding.distsql.checker;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.sharding.exception.strategy.InvalidShardingStrategyConfigurationException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.exception.rule.MissingRequiredRuleException;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingImportRuleConfigurationProviderTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingImportRuleConfigurationProviderTest.java
deleted file mode 100644
index 5eb7653c748..00000000000
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingImportRuleConfigurationProviderTest.java
+++ /dev/null
@@ -1,93 +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.distsql.provider;
-
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationChecker;
-import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.distsql.handler.provider.ShardingImportRuleConfigurationProvider;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-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.when;
-
-class ShardingImportRuleConfigurationProviderTest {
-    
-    @Test
-    void assertCheckLogicTables() {
-        assertThrows(DuplicateRuleException.class, () -> new ShardingImportRuleConfigurationProvider().check("foo_db", createDuplicatedTablesRuleConfiguration()));
-    }
-    
-    @Test
-    void assertCheckDataSources() {
-        ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
-        currentRuleConfig.getTables().add(new ShardingTableRuleConfiguration("t_order", "ds_${0..2}.t_order_${0..2}"));
-        assertThrows(MissingRequiredStorageUnitsException.class, () -> ImportRuleConfigurationChecker.checkRule(currentRuleConfig, mockDatabaseWithDataSource()));
-    }
-    
-    @Test
-    void assertCheckKeyGenerators() {
-        assertThrows(ServiceProviderNotFoundException.class, () -> new ShardingImportRuleConfigurationProvider().check("foo_db", createInvalidKeyGeneratorRuleConfiguration()));
-    }
-    
-    @Test
-    void assertCheckShardingAlgorithms() {
-        assertThrows(ServiceProviderNotFoundException.class, () -> new ShardingImportRuleConfigurationProvider().check("foo_db", createInvalidShardingAlgorithmRuleConfiguration()));
-    }
-    
-    private ShardingRuleConfiguration createDuplicatedTablesRuleConfiguration() {
-        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.getTables().add(new ShardingTableRuleConfiguration("t_order", null));
-        result.getTables().add(new ShardingTableRuleConfiguration("t_order", null));
-        return result;
-    }
-    
-    private ShardingSphereDatabase mockDatabaseWithDataSource() {
-        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
-        Collection<String> dataSources = new LinkedList<>();
-        dataSources.add("su_1");
-        when(result.getResourceMetaData().getNotExistedDataSources(any())).thenReturn(dataSources);
-        when(result.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.emptyList()));
-        return result;
-    }
-    
-    private ShardingRuleConfiguration createInvalidKeyGeneratorRuleConfiguration() {
-        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.getKeyGenerators().put("Invalid_key_generator", mock(AlgorithmConfiguration.class));
-        return result;
-    }
-    
-    private ShardingRuleConfiguration createInvalidShardingAlgorithmRuleConfiguration() {
-        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.getShardingAlgorithms().put("Invalid_algorithm", mock(AlgorithmConfiguration.class));
-        return result;
-    }
-}
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyExecutorTest.java
index 09991cd9ebc..12557ce15ed 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterDefaultShardingStrategyExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyExecutorTest.java
index 75380b4d152..a0e66207b4e 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
index 5d0d41f9c4c..85c89e35657 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleExecutorTest.java
@@ -21,7 +21,7 @@ import lombok.SneakyThrows;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
+import org.apache.shardingsphere.infra.exception.algorithm.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
@@ -138,7 +138,7 @@ class CreateShardingTableRuleExecutorTest {
                 + "TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_order_item_${order_id % 4}')),"
                 + "KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME='snowflake')))";
         CreateShardingTableRuleStatement distSQLStatement = (CreateShardingTableRuleStatement) getDistSQLStatement(sql);
-        assertThrows(DistSQLException.class, () -> executor.checkBeforeUpdate(distSQLStatement));
+        assertThrows(InvalidAlgorithmConfigurationException.class, () -> executor.checkBeforeUpdate(distSQLStatement));
     }
     
     @Test
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
index da84381abbe..84e88ef6338 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.RuleDefinitionException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorExecutorTest.java
index 787f47b25dd..3923ac49207 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorExecutorTest.java
index 6451e8f4388..d7b571be1a3 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorExecutorTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.update;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationChecker.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationCheckEngine.java
similarity index 70%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationChecker.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationCheckEngine.java
index 5578532f400..1a7b8660c6a 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationChecker.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationCheckEngine.java
@@ -15,26 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database;
+package org.apache.shardingsphere.infra.config.rule.checker;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.storageunit.MissingRequiredStorageUnitsException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
 
+import javax.sql.DataSource;
 import java.util.Collection;
-import java.util.Optional;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Map.Entry;
 import java.util.stream.Collectors;
 
 /**
- * Import rule configuration checker.
+ * Rule configuration check engine.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ImportRuleConfigurationChecker {
+public final class RuleConfigurationCheckEngine {
     
     /**
      * Check rule.
@@ -44,14 +47,13 @@ public final class ImportRuleConfigurationChecker {
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
     public static void checkRule(final RuleConfiguration ruleConfig, final ShardingSphereDatabase database) {
-        Optional<ImportRuleConfigurationProvider> importProvider = TypedSPILoader.findService(ImportRuleConfigurationProvider.class, ruleConfig.getClass());
-        if (importProvider.isPresent()) {
-            Collection<String> requiredDataSourceNames = importProvider.get().getRequiredDataSourceNames(ruleConfig);
-            if (!requiredDataSourceNames.isEmpty()) {
-                checkDataSourcesExisted(database, requiredDataSourceNames);
-            }
-            importProvider.get().check(database.getName(), ruleConfig);
+        RuleConfigurationChecker configChecker = OrderedSPILoader.getServicesByClass(RuleConfigurationChecker.class, Collections.singleton(ruleConfig.getClass())).get(ruleConfig.getClass());
+        Collection<String> requiredDataSourceNames = configChecker.getRequiredDataSourceNames(ruleConfig);
+        if (!requiredDataSourceNames.isEmpty()) {
+            checkDataSourcesExisted(database, requiredDataSourceNames);
         }
+        Map<String, DataSource> dataSources = database.getResourceMetaData().getStorageUnits().entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getDataSource()));
+        configChecker.check(database.getName(), ruleConfig, dataSources, database.getRuleMetaData().getRules());
     }
     
     private static void checkDataSourcesExisted(final ShardingSphereDatabase database, final Collection<String> requiredDataSourceNames) {
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationChecker.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationChecker.java
index 96898b169b2..ebd03cd97b9 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationChecker.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/rule/checker/RuleConfigurationChecker.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
 
 import javax.sql.DataSource;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 /**
@@ -43,4 +44,14 @@ public interface RuleConfigurationChecker<T extends RuleConfiguration> extends O
      * @param builtRules built rules
      */
     void check(String databaseName, T ruleConfig, Map<String, DataSource> dataSourceMap, Collection<ShardingSphereRule> builtRules);
+    
+    /**
+     * Get required data source names.
+     *
+     * @param ruleConfig rule configuration
+     * @return required data source names
+     */
+    default Collection<String> getRequiredDataSourceNames(T ruleConfig) {
+        return Collections.emptyList();
+    }
 }
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmInUsedException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/AlgorithmInUsedException.java
similarity index 87%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmInUsedException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/AlgorithmInUsedException.java
index 17e76411f4d..284237b080a 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmInUsedException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/AlgorithmInUsedException.java
@@ -15,16 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.algorithm;
+package org.apache.shardingsphere.infra.exception.algorithm;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.AlgorithmDefinitionException;
 
 import java.util.Collection;
 
 /**
  * Algorithm in used exception.
  */
-public final class AlgorithmInUsedException extends AlgorithmDefinitionViolationException {
+public final class AlgorithmInUsedException extends AlgorithmDefinitionException {
     
     private static final long serialVersionUID = -8735125626190637177L;
     
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/DuplicateAlgorithmException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/DuplicateAlgorithmException.java
similarity index 87%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/DuplicateAlgorithmException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/DuplicateAlgorithmException.java
index 9e2644a42f0..2e3b85e7f5e 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/DuplicateAlgorithmException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/DuplicateAlgorithmException.java
@@ -15,16 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.algorithm;
+package org.apache.shardingsphere.infra.exception.algorithm;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.AlgorithmDefinitionException;
 
 import java.util.Collection;
 
 /**
  * Duplicate algorithm exception.
  */
-public final class DuplicateAlgorithmException extends AlgorithmDefinitionViolationException {
+public final class DuplicateAlgorithmException extends AlgorithmDefinitionException {
     
     private static final long serialVersionUID = 3503761639898230997L;
     
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/InvalidAlgorithmConfigurationException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/InvalidAlgorithmConfigurationException.java
similarity index 90%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/InvalidAlgorithmConfigurationException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/InvalidAlgorithmConfigurationException.java
index 29ac56f6334..871c2745091 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/InvalidAlgorithmConfigurationException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/InvalidAlgorithmConfigurationException.java
@@ -15,16 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.algorithm;
+package org.apache.shardingsphere.infra.exception.algorithm;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.AlgorithmDefinitionException;
 
 import java.util.Collection;
 
 /**
  * Invalid algorithm configuration exception.
  */
-public final class InvalidAlgorithmConfigurationException extends AlgorithmDefinitionViolationException {
+public final class InvalidAlgorithmConfigurationException extends AlgorithmDefinitionException {
     
     private static final long serialVersionUID = 1352014079406440573L;
     
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/MissingRequiredAlgorithmException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/MissingRequiredAlgorithmException.java
similarity index 90%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/MissingRequiredAlgorithmException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/MissingRequiredAlgorithmException.java
index ea2b20ca1ae..bec1eb2effe 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/MissingRequiredAlgorithmException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/algorithm/MissingRequiredAlgorithmException.java
@@ -15,16 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.algorithm;
+package org.apache.shardingsphere.infra.exception.algorithm;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.AlgorithmDefinitionException;
 
 import java.util.Collection;
 
 /**
  * Missing required algorithm exception.
  */
-public final class MissingRequiredAlgorithmException extends AlgorithmDefinitionViolationException {
+public final class MissingRequiredAlgorithmException extends AlgorithmDefinitionException {
     
     private static final long serialVersionUID = 4591071898233749618L;
     
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationProvider.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationProvider.java
deleted file mode 100644
index 91d964bc918..00000000000
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/ral/rule/spi/database/ImportRuleConfigurationProvider.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.distsql.handler.engine.update.ral.rule.spi.database;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Import rule configuration provider.
- * 
- * @param <T> type of rule configuration
- */
-@SingletonSPI
-public interface ImportRuleConfigurationProvider<T extends RuleConfiguration> extends TypedSPI {
-    
-    /**
-     * Check rule configuration.
-     *
-     * @param databaseName database name
-     * @param ruleConfig rule configuration
-     */
-    void check(String databaseName, T ruleConfig);
-    
-    /**
-     * Get required data source names.
-     *
-     * @param ruleConfig rule configuration
-     * @return required data source names
-     */
-    default Collection<String> getRequiredDataSourceNames(T ruleConfig) {
-        return Collections.emptyList();
-    }
-    
-    @Override
-    Class<T> getType();
-}
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmDefinitionViolationException.java b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/AlgorithmDefinitionException.java
similarity index 63%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmDefinitionViolationException.java
rename to infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/AlgorithmDefinitionException.java
index 0d85728da4e..6ca961f3c8c 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/algorithm/AlgorithmDefinitionViolationException.java
+++ b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/AlgorithmDefinitionException.java
@@ -15,19 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.exception.algorithm;
+package org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category;
 
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.KernelSQLException;
 
 /**
- * Algorithm definition violation exception.
+ * Algorithm definition exception.
  */
-public abstract class AlgorithmDefinitionViolationException extends DistSQLException {
+public abstract class AlgorithmDefinitionException extends KernelSQLException {
     
-    private static final long serialVersionUID = -727466071244178933L;
+    private static final long serialVersionUID = -8947223495845000542L;
     
-    protected AlgorithmDefinitionViolationException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
-        super(sqlState, errorCode, reason, messageArgs);
+    private static final int KERNEL_CODE = 9;
+    
+    protected AlgorithmDefinitionException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
+        super(sqlState, KERNEL_CODE, errorCode, reason, messageArgs);
     }
 }
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
index d371180e689..c1ef1eab15a 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
 
-import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import org.apache.shardingsphere.infra.exception.algorithm.MissingRequiredAlgorithmException;
 import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorClusterModeRequired;
 import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.LockClusterStatement;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
index c682f4ac29e..f21f94119d6 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.proxy.backend.util;
 
-import org.apache.shardingsphere.distsql.handler.engine.update.ral.rule.spi.database.ImportRuleConfigurationChecker;
+import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationCheckEngine;
 import org.apache.shardingsphere.distsql.handler.exception.datasource.MissingRequiredDataSourcesException;
 import org.apache.shardingsphere.infra.exception.storageunit.InvalidStorageUnitsException;
 import org.apache.shardingsphere.distsql.handler.validate.DataSourcePoolPropertiesValidator;
@@ -140,7 +140,7 @@ public final class YamlDatabaseConfigurationImportExecutor {
     }
     
     private void addRule(final Collection<RuleConfiguration> ruleConfigs, final RuleConfiguration ruleConfig, final ShardingSphereDatabase database) {
-        ImportRuleConfigurationChecker.checkRule(ruleConfig, database);
+        RuleConfigurationCheckEngine.checkRule(ruleConfig, database);
         ruleConfigs.add(ruleConfig);
         database.getRuleMetaData().getRules().add(buildRule(ruleConfig, database));
     }