You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/05/17 10:00:30 UTC

[shardingsphere] branch master updated: Refactor PersistedYamlConfigurationWrapper (#10365)

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

menghaoran 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 b86fc64  Refactor PersistedYamlConfigurationWrapper (#10365)
b86fc64 is described below

commit b86fc64bda9d4806f63914a2e52fef1e8300cfb1
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon May 17 17:59:45 2021 +0800

    Refactor PersistedYamlConfigurationWrapper (#10365)
    
    * Refactor PersistedYamlConfigurationWrapper
    
    * Refactor PersistedYamlConfigurationWrapper
    
    * Refactor PersistedYamlConfigurationWrapper
    
    * Refactor PersistedYamlConfigurationWrapper
    
    * For checkstyle
---
 .../listener/PrivilegeNodeChangedListener.java     |  8 ++-
 .../authority/listener/UserChangedListener.java    |  8 ++-
 .../governance/core/registry/RegistryCenter.java   | 10 +--
 .../wrapper/PersistedYamlConfigurationWrapper.java | 76 +++-------------------
 .../ShardingSphereJDBCDataSourceConfiguration.java |  7 +-
 .../yaml/ShardingRuleConfigurationSwapper.java     | 45 +++++++++++++
 .../scaling/core/util/JobConfigurationUtil.java    | 10 +--
 .../scaling/core/util/JDBCUtilTest.java            |  2 +-
 8 files changed, 80 insertions(+), 86 deletions(-)

diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/PrivilegeNodeChangedListener.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/PrivilegeNodeChangedListener.java
index b33a802..951d4f4 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/PrivilegeNodeChangedListener.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/PrivilegeNodeChangedListener.java
@@ -21,10 +21,12 @@ import org.apache.shardingsphere.governance.context.authority.listener.event.Aut
 import org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
 import org.apache.shardingsphere.governance.core.registry.listener.PostGovernanceRepositoryEventListener;
 import org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
-import org.apache.shardingsphere.governance.core.yaml.persisted.wrapper.PersistedYamlConfigurationWrapper;
-import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
 import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
+import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Optional;
 
@@ -39,6 +41,6 @@ public final class PrivilegeNodeChangedListener extends PostGovernanceRepository
     
     @Override
     protected Optional<GovernanceEvent> createEvent(final DataChangedEvent event) {
-        return Optional.of(new AuthorityChangedEvent(PersistedYamlConfigurationWrapper.convertUsers(event.getValue())));
+        return Optional.of(new AuthorityChangedEvent(YamlUsersConfigurationConverter.convertShardingSphereUser(YamlEngine.unmarshal(event.getValue(), Collection.class))));
     }
 }
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/UserChangedListener.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/UserChangedListener.java
index 66a12cc..6054d84 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/UserChangedListener.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/listener/UserChangedListener.java
@@ -21,10 +21,12 @@ import org.apache.shardingsphere.governance.context.authority.listener.event.Aut
 import org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
 import org.apache.shardingsphere.governance.core.registry.listener.PostGovernanceRepositoryEventListener;
 import org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
-import org.apache.shardingsphere.governance.core.yaml.persisted.wrapper.PersistedYamlConfigurationWrapper;
-import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
 import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
+import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Optional;
 
@@ -39,6 +41,6 @@ public final class UserChangedListener extends PostGovernanceRepositoryEventList
     
     @Override
     protected Optional<GovernanceEvent> createEvent(final DataChangedEvent event) {
-        return Optional.of(new AuthorityChangedEvent(PersistedYamlConfigurationWrapper.convertUsers(event.getValue())));
+        return Optional.of(new AuthorityChangedEvent(YamlUsersConfigurationConverter.convertShardingSphereUser(YamlEngine.unmarshal(event.getValue(), Collection.class))));
     }
 }
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
index 4ba77e6..ec41d2b 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
@@ -266,7 +266,7 @@ public final class RegistryCenter {
      */
     public Map<String, DataSourceConfiguration> loadDataSourceConfigurations(final String schemaName) {
         return hasDataSourceConfiguration(schemaName)
-                ? PersistedYamlConfigurationWrapper.convertDataSourceConfigurations(repository.get(node.getMetadataDataSourcePath(schemaName))) : new LinkedHashMap<>();
+                ? PersistedYamlConfigurationWrapper.unwrapDataSourceConfigurations(repository.get(node.getMetadataDataSourcePath(schemaName))) : new LinkedHashMap<>();
     }
     
     /**
@@ -276,7 +276,7 @@ public final class RegistryCenter {
      * @return rule configurations
      */
     public Collection<RuleConfiguration> loadRuleConfigurations(final String schemaName) {
-        return hasRuleConfiguration(schemaName) ? PersistedYamlConfigurationWrapper.convertRuleConfigurations(repository.get(node.getRulePath(schemaName))) : new LinkedList<>();
+        return hasRuleConfiguration(schemaName) ? PersistedYamlConfigurationWrapper.unwrapRuleConfigurations(repository.get(node.getRulePath(schemaName))) : new LinkedList<>();
     }
     
     /**
@@ -285,7 +285,7 @@ public final class RegistryCenter {
      * @return users
      */
     public Collection<ShardingSphereUser> loadUsers() {
-        return hasUsers() ? PersistedYamlConfigurationWrapper.convertUsers(repository.get(node.getUsersNode())) : Collections.emptyList();
+        return hasUsers() ? YamlUsersConfigurationConverter.convertShardingSphereUser(YamlEngine.unmarshal(repository.get(node.getUsersNode()), Collection.class)) : Collections.emptyList();
     }
     
     /**
@@ -294,7 +294,7 @@ public final class RegistryCenter {
      * @return properties
      */
     public Properties loadProperties() {
-        return Strings.isNullOrEmpty(repository.get(node.getPropsPath())) ? new Properties() : PersistedYamlConfigurationWrapper.convertProperties(repository.get(node.getPropsPath()));
+        return Strings.isNullOrEmpty(repository.get(node.getPropsPath())) ? new Properties() : YamlEngine.unmarshal(repository.get(node.getPropsPath()), Properties.class);
     }
     
     /**
@@ -303,7 +303,7 @@ public final class RegistryCenter {
      * @return global rule configurations
      */
     public Collection<RuleConfiguration> loadGlobalRuleConfigurations() {
-        return hasGlobalRuleConfigurations() ? PersistedYamlConfigurationWrapper.convertRuleConfigurations(repository.get(node.getGlobalRuleNode())) : Collections.emptyList();
+        return hasGlobalRuleConfigurations() ? PersistedYamlConfigurationWrapper.unwrapRuleConfigurations(repository.get(node.getGlobalRuleNode())) : Collections.emptyList();
     }
     
     /**
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/wrapper/PersistedYamlConfigurationWrapper.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/wrapper/PersistedYamlConfigurationWrapper.java
index d6f3320..e3059c9 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/wrapper/PersistedYamlConfigurationWrapper.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/wrapper/PersistedYamlConfigurationWrapper.java
@@ -17,29 +17,19 @@
 
 package org.apache.shardingsphere.governance.core.yaml.persisted.wrapper;
 
-import com.google.common.base.Preconditions;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.governance.core.yaml.persisted.pojo.PersistedYamlDataSourceConfiguration;
 import org.apache.shardingsphere.governance.core.yaml.persisted.pojo.PersistedYamlRuleConfiguration;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
 import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 import org.apache.shardingsphere.infra.yaml.swapper.YamlDataSourceConfigurationSwapper;
 import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.yaml.swapper.ShardingRuleConfigurationYamlSwapper;
 
-import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
 
 /**
  * Configuration wrapper for YAML content.
@@ -48,83 +38,35 @@ import java.util.Properties;
 public final class PersistedYamlConfigurationWrapper {
     
     /**
-     * Convert data source configurations from YAML content.
+     * Unwrap data source configuration map from YAML content.
      *
      * @param yamlContent YAML content
-     * @return data source configurations
+     * @return data source configuration map
      */
-    public static Map<String, DataSourceConfiguration> convertDataSourceConfigurations(final String yamlContent) {
-        PersistedYamlDataSourceConfiguration result = YamlEngine.unmarshal(yamlContent, PersistedYamlDataSourceConfiguration.class);
-        if (null == result.getDataSources() || result.getDataSources().isEmpty()) {
-            return new LinkedHashMap<>();
-        }
-        return convertDataSourceConfigurations(result.getDataSources());
+    public static Map<String, DataSourceConfiguration> unwrapDataSourceConfigurations(final String yamlContent) {
+        PersistedYamlDataSourceConfiguration persistedConfig = YamlEngine.unmarshal(yamlContent, PersistedYamlDataSourceConfiguration.class);
+        return null == persistedConfig.getDataSources() || persistedConfig.getDataSources().isEmpty() ? new LinkedHashMap<>() : unwrapDataSourceConfigurations(persistedConfig.getDataSources());
     }
     
     /**
-     * Convert data source configurations from YAML content.
+     * Unwrap data source configurations from YAML content.
      *
      * @param yamlDataSourceConfigs YAML data source configurations
      * @return data source configurations
      */
-    public static Map<String, DataSourceConfiguration> convertDataSourceConfigurations(final Map<String, Map<String, Object>> yamlDataSourceConfigs) {
+    public static Map<String, DataSourceConfiguration> unwrapDataSourceConfigurations(final Map<String, Map<String, Object>> yamlDataSourceConfigs) {
         Map<String, DataSourceConfiguration> result = new LinkedHashMap<>(yamlDataSourceConfigs.size());
         yamlDataSourceConfigs.forEach((key, value) -> result.put(key, new YamlDataSourceConfigurationSwapper().swapToDataSourceConfiguration(value)));
         return result;
     }
     
     /**
-     * Convert data sources from YAML data source configurations.
-     *
-     * @param yamlDataSources YAML data sources
-     * @return data sources
-     */
-    public static Map<String, DataSource> convertDataSources(final Map<String, Map<String, Object>> yamlDataSources) {
-        return new YamlDataSourceConfigurationSwapper().swapToDataSources(yamlDataSources);
-    }
-    
-    /**
-     * Convert sharding rule configuration from YAML .
-     *
-     * @param yamlRuleConfigs yaml rule configurations
-     * @return sharding rule configuration
-     */
-    public static ShardingRuleConfiguration convertShardingRuleConfig(final Collection<YamlRuleConfiguration> yamlRuleConfigs) {
-        Optional<YamlRuleConfiguration> ruleConfig = yamlRuleConfigs.stream()
-                .filter(each -> each instanceof YamlShardingRuleConfiguration)
-                .findFirst();
-        Preconditions.checkState(ruleConfig.isPresent(), "No available sharding rule to load for governance.");
-        return new ShardingRuleConfigurationYamlSwapper().swapToObject((YamlShardingRuleConfiguration) ruleConfig.get());
-    }
-    
-    /**
-     * Convert rule configurations from YAML content.
+     * Unwrap rule configurations from YAML content.
      *
      * @param yamlContent YAML content
      * @return rule configurations
      */
-    public static Collection<RuleConfiguration> convertRuleConfigurations(final String yamlContent) {
+    public static Collection<RuleConfiguration> unwrapRuleConfigurations(final String yamlContent) {
         return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(yamlContent, PersistedYamlRuleConfiguration.class).getRules());
     }
-    
-    /**
-     * Convert users from YAML content.
-     *
-     * @param yamlContent YAML content
-     * @return users
-     */
-    public static Collection<ShardingSphereUser> convertUsers(final String yamlContent) {
-        Collection<String> users = YamlEngine.unmarshal(yamlContent, Collection.class);
-        return YamlUsersConfigurationConverter.convertShardingSphereUser(users);
-    }
-    
-    /**
-     * Convert properties configuration from YAML content.
-     *
-     * @param yamlContent YAML content
-     * @return properties
-     */
-    public static Properties convertProperties(final String yamlContent) {
-        return YamlEngine.unmarshal(yamlContent, Properties.class);
-    }
 }
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
index d22fd71..9f7c30e 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
@@ -21,11 +21,12 @@ import com.google.common.collect.Lists;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.governance.core.yaml.persisted.wrapper.PersistedYamlConfigurationWrapper;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
 import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlDataSourceConfigurationSwapper;
+import org.apache.shardingsphere.scaling.core.config.yaml.ShardingRuleConfigurationSwapper;
 import org.apache.shardingsphere.scaling.core.util.JDBCUtil;
 
 import javax.sql.DataSource;
@@ -71,7 +72,7 @@ public final class ShardingSphereJDBCDataSourceConfiguration implements ScalingD
     
     @Override
     public DataSource toDataSource() throws SQLException {
-        return ShardingSphereDataSourceFactory.createDataSource(PersistedYamlConfigurationWrapper.convertDataSources(rootRuleConfigs.getDataSources()),
-                Lists.newArrayList(PersistedYamlConfigurationWrapper.convertShardingRuleConfig(rootRuleConfigs.getRules())), null);
+        return ShardingSphereDataSourceFactory.createDataSource(new YamlDataSourceConfigurationSwapper().swapToDataSources(rootRuleConfigs.getDataSources()),
+                Lists.newArrayList(ShardingRuleConfigurationSwapper.findAndConvertShardingRuleConfiguration(rootRuleConfigs.getRules())), null);
     }
 }
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ShardingRuleConfigurationSwapper.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ShardingRuleConfigurationSwapper.java
new file mode 100644
index 0000000..b8a6139
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ShardingRuleConfigurationSwapper.java
@@ -0,0 +1,45 @@
+/*
+ * 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.scaling.core.config.yaml;
+
+import com.google.common.base.Preconditions;
+import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.swapper.ShardingRuleConfigurationYamlSwapper;
+
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Sharding rule configuration swapper.
+ */
+public final class ShardingRuleConfigurationSwapper {
+    
+    /**
+     * Find and convert sharding rule configuration from YAML .
+     *
+     * @param yamlRuleConfigs YAML rule configurations
+     * @return sharding rule configuration
+     */
+    public static ShardingRuleConfiguration findAndConvertShardingRuleConfiguration(final Collection<YamlRuleConfiguration> yamlRuleConfigs) {
+        Optional<YamlRuleConfiguration> ruleConfig = yamlRuleConfigs.stream().filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst();
+        Preconditions.checkState(ruleConfig.isPresent(), "No available sharding rule to load for governance.");
+        return new ShardingRuleConfigurationYamlSwapper().swapToObject((YamlShardingRuleConfiguration) ruleConfig.get());
+    }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/util/JobConfigurationUtil.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/util/JobConfigurationUtil.java
index a965e77..798b218 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/util/JobConfigurationUtil.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/util/JobConfigurationUtil.java
@@ -39,6 +39,7 @@ import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
 import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
 import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
 import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.yaml.ShardingRuleConfigurationSwapper;
 import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
 import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineExpressionParser;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -157,7 +158,7 @@ public final class JobConfigurationUtil {
     }
     
     private static Map<String, ShardingTableRuleConfiguration> getShardingRuleConfigMap(final YamlRootRuleConfigurations rootRuleConfigurations) {
-        ShardingRuleConfiguration ruleConfig = PersistedYamlConfigurationWrapper.convertShardingRuleConfig(rootRuleConfigurations.getRules());
+        ShardingRuleConfiguration ruleConfig = ShardingRuleConfigurationSwapper.findAndConvertShardingRuleConfiguration(rootRuleConfigurations.getRules());
         return ruleConfig.getTables().stream()
                 .collect(Collectors.toMap(ShardingTableRuleConfiguration::getLogicTable, Function.identity()));
     }
@@ -219,8 +220,8 @@ public final class JobConfigurationUtil {
     public static List<TaskConfiguration> toTaskConfigs(final JobConfiguration jobConfig) {
         List<TaskConfiguration> result = new LinkedList<>();
         ShardingSphereJDBCDataSourceConfiguration sourceConfig = getSourceConfig(jobConfig);
-        ShardingRuleConfiguration sourceRuleConfig = PersistedYamlConfigurationWrapper.convertShardingRuleConfig(sourceConfig.getRootRuleConfigs().getRules());
-        Map<String, DataSourceConfiguration> sourceDataSource = PersistedYamlConfigurationWrapper.convertDataSourceConfigurations(sourceConfig.getRootRuleConfigs().getDataSources());
+        ShardingRuleConfiguration sourceRuleConfig = ShardingRuleConfigurationSwapper.findAndConvertShardingRuleConfiguration(sourceConfig.getRootRuleConfigs().getRules());
+        Map<String, DataSourceConfiguration> sourceDataSource = PersistedYamlConfigurationWrapper.unwrapDataSourceConfigurations(sourceConfig.getRootRuleConfigs().getDataSources());
         Map<String, DataSource> dataSourceMap = sourceDataSource.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().createDataSource()));
         Map<String, Map<String, String>> dataSourceTableNameMap = toDataSourceTableNameMap(new ShardingRule(sourceRuleConfig, sourceConfig.getDatabaseType(), dataSourceMap));
         Optional<ShardingRuleConfiguration> targetRuleConfig = getTargetRuleConfig(jobConfig);
@@ -243,7 +244,8 @@ public final class JobConfigurationUtil {
     private static Optional<ShardingRuleConfiguration> getTargetRuleConfig(final JobConfiguration jobConfig) {
         ScalingDataSourceConfiguration dataSourceConfig = jobConfig.getRuleConfig().getTarget().unwrap();
         if (dataSourceConfig instanceof ShardingSphereJDBCDataSourceConfiguration) {
-            return Optional.of(PersistedYamlConfigurationWrapper.convertShardingRuleConfig(((ShardingSphereJDBCDataSourceConfiguration) dataSourceConfig).getRootRuleConfigs().getRules()));
+            return Optional.of(
+                    ShardingRuleConfigurationSwapper.findAndConvertShardingRuleConfiguration(((ShardingSphereJDBCDataSourceConfiguration) dataSourceConfig).getRootRuleConfigs().getRules()));
         }
         return Optional.empty();
     }
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
index da70304..a19c857 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
@@ -42,7 +42,7 @@ public final class JDBCUtilTest {
     public void assertAppendShardingSphereJDBCDataSourceConfig() {
         ShardingSphereJDBCDataSourceConfiguration dataSourceConfig = new ShardingSphereJDBCDataSourceConfiguration(mockDataSource(), "");
         JDBCUtil.appendJDBCParameter(dataSourceConfig, ImmutableMap.<String, String>builder().put("rewriteBatchedStatements", "true").build());
-        ArrayList<DataSourceConfiguration> actual = new ArrayList<>(PersistedYamlConfigurationWrapper.convertDataSourceConfigurations(dataSourceConfig.getRootRuleConfigs().getDataSources()).values());
+        ArrayList<DataSourceConfiguration> actual = new ArrayList<>(PersistedYamlConfigurationWrapper.unwrapDataSourceConfigurations(dataSourceConfig.getRootRuleConfigs().getDataSources()).values());
         assertThat(actual.get(0).getProps().get("url"), is("jdbc:mysql://192.168.0.2:3306/scaling?rewriteBatchedStatements=true&serverTimezone=UTC&useSSL=false"));
         assertThat(actual.get(1).getProps().get("url"), is("jdbc:mysql://192.168.0.1:3306/scaling?rewriteBatchedStatements=true&serverTimezone=UTC&useSSL=false"));
     }