You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/08/01 05:14:00 UTC

[shardingsphere] branch master updated: Remove ProxyConfigurationConverter (#6564)

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

panjuan 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 dc5585c  Remove ProxyConfigurationConverter (#6564)
dc5585c is described below

commit dc5585c8e3a96fc8bf0886d915ed403ed90443a8
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Aug 1 13:10:19 2020 +0800

    Remove ProxyConfigurationConverter (#6564)
    
    * rename Bootstrap.init
    
    * Refactor Bootstrap.log
    
    * Remove useless javadoc
    
    * Add final
    
    * Revise ProxyConfiguration
    
    * Revise DataSourceParameter
    
    * Revise DataSourceParameter
    
    * Refactor OrchestrationConfigurationConverter
    
    * Add OrchestrationBootstrap
    
    * Add YamlProxyConfigurationSwapper
    
    * Remove ProxyConfigurationConverter
    
    * Refactor Bootstrap
    
    * Refactor Bootstrap
    
    * Refactor Bootstrap
    
    * Remove Serializable for ProxyConfiguration
    
    * refactor OrchestrationBootstrap
    
    * For checkstyle
---
 .../kernel/context/schema/DataSourceParameter.java | 10 +--
 .../org/apache/shardingsphere/proxy/Bootstrap.java | 51 +++++++------
 .../orchestration/OrchestrationBootstrap.java}     | 88 ++++++++++------------
 .../proxy/config/ProxyConfiguration.java           | 21 +++---
 .../converter/AbstractConfigurationConverter.java  | 69 -----------------
 .../converter/DefaultConfigurationConverter.java   | 69 -----------------
 .../converter/ProxyConfigurationConverter.java     | 48 ------------
 .../ProxyConfigurationConverterFactory.java        | 47 ------------
 .../proxy/config/yaml/YamlDataSourceParameter.java |  2 +-
 .../config/yaml/YamlProxyServerConfiguration.java  |  4 +-
 .../swapper/YamlProxyConfigurationSwapper.java     | 79 +++++++++++++++++++
 ...xy.config.converter.ProxyConfigurationConverter | 18 -----
 12 files changed, 166 insertions(+), 340 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-kernel-context/src/main/java/org/apache/shardingsphere/kernel/context/schema/DataSourceParameter.java b/shardingsphere-kernel/shardingsphere-kernel-context/src/main/java/org/apache/shardingsphere/kernel/context/schema/DataSourceParameter.java
index 6d157f1..8d13b80 100644
--- a/shardingsphere-kernel/shardingsphere-kernel-context/src/main/java/org/apache/shardingsphere/kernel/context/schema/DataSourceParameter.java
+++ b/shardingsphere-kernel/shardingsphere-kernel-context/src/main/java/org/apache/shardingsphere/kernel/context/schema/DataSourceParameter.java
@@ -22,7 +22,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 /**
- * Data source parameters for YAML.
+ * Data source parameters.
  */
 @Getter
 @Setter
@@ -35,9 +35,9 @@ public final class DataSourceParameter {
     
     private String password;
     
-    private long connectionTimeoutMilliseconds = 30 * 1000;
+    private long connectionTimeoutMilliseconds = 30 * 1000L;
     
-    private long idleTimeoutMilliseconds = 60 * 1000;
+    private long idleTimeoutMilliseconds = 60 * 1000L;
     
     private long maxLifetimeMilliseconds;
     
@@ -45,7 +45,7 @@ public final class DataSourceParameter {
     
     private int minPoolSize = 1;
     
-    private long maintenanceIntervalMilliseconds = 30 * 1000;
-
+    private long maintenanceIntervalMilliseconds = 30 * 1000L;
+    
     private boolean readOnly;
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
index 6d1f6f8..0916721 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
@@ -35,9 +35,11 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypes;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.log.ConfigurationLogger;
+import org.apache.shardingsphere.kernel.context.SchemaContextsAware;
 import org.apache.shardingsphere.kernel.context.SchemaContextsBuilder;
 import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
 import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
+import org.apache.shardingsphere.orchestration.core.facade.OrchestrationFacade;
 import org.apache.shardingsphere.proxy.arg.BootstrapArguments;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCRawBackendDataSourceFactory;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.JDBCDriverURLRecognizerEngine;
@@ -45,9 +47,10 @@ import org.apache.shardingsphere.proxy.backend.schema.ProxySchemaContexts;
 import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
 import org.apache.shardingsphere.proxy.config.ProxyConfigurationLoader;
 import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
-import org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverter;
-import org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverterFactory;
+import org.apache.shardingsphere.proxy.config.yaml.swapper.YamlProxyConfigurationSwapper;
 import org.apache.shardingsphere.proxy.frontend.bootstrap.ShardingSphereProxy;
+import org.apache.shardingsphere.proxy.orchestration.OrchestrationBootstrap;
+import org.apache.shardingsphere.proxy.orchestration.schema.ProxyOrchestrationSchemaContexts;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -81,40 +84,40 @@ public final class Bootstrap {
         int port = bootstrapArgs.getPort();
         System.setProperty(Constants.PORT_KEY, String.valueOf(port));
         YamlProxyConfiguration yamlConfig = ProxyConfigurationLoader.load(bootstrapArgs.getConfigurationPath());
-        try (ProxyConfigurationConverter converter = ProxyConfigurationConverterFactory.newInstances(null != yamlConfig.getServerConfiguration().getOrchestration())) {
-            ProxyConfiguration proxyConfiguration = converter.convert(yamlConfig);
-            log(proxyConfiguration);
-            initialize(proxyConfiguration, port, converter);
-        }
-    }
-    
-    private static void log(final ProxyConfiguration proxyConfiguration) {
-        Collection<Collection<RuleConfiguration>> ruleConfigurations = proxyConfiguration.getSchemaRules().values();
-        if (CollectionUtils.isNotEmpty(ruleConfigurations)) {
-            ruleConfigurations.forEach(ConfigurationLogger::log);
+        if (null == yamlConfig.getServerConfiguration().getOrchestration()) {
+            init(new YamlProxyConfigurationSwapper().swap(yamlConfig), port);
+        } else {
+            try (OrchestrationFacade orchestrationFacade = OrchestrationFacade.getInstance()) {
+                init(new OrchestrationBootstrap(orchestrationFacade).init(yamlConfig), port);
+            }
         }
-        ConfigurationLogger.log(proxyConfiguration.getAuthentication());
-        ConfigurationLogger.log(proxyConfiguration.getProps());
     }
     
-    private static void initialize(final ProxyConfiguration proxyConfiguration, final int port, final ProxyConfigurationConverter converter) throws SQLException {
-        Authentication authentication = proxyConfiguration.getAuthentication();
-        Properties props = proxyConfiguration.getProps();
-        initProxySchemaContexts(proxyConfiguration.getSchemaDataSources(), proxyConfiguration.getSchemaRules(), authentication, props, converter);
-        initControlPanelFacade(proxyConfiguration.getMetrics(), proxyConfiguration.getCluster());
+    private static void init(final ProxyConfiguration proxyConfig, final int port) throws SQLException {
+        log(proxyConfig);
+        Authentication authentication = proxyConfig.getAuthentication();
+        Properties props = proxyConfig.getProps();
+        initProxySchemaContexts(proxyConfig.getSchemaDataSources(), proxyConfig.getSchemaRules(), authentication, props);
+        initControlPanelFacade(proxyConfig.getMetrics(), proxyConfig.getCluster());
         updateServerInfo();
         ShardingSphereProxy.getInstance().start(port);
     }
     
+    private static void log(final ProxyConfiguration proxyConfig) {
+        proxyConfig.getSchemaRules().values().forEach(ConfigurationLogger::log);
+        ConfigurationLogger.log(proxyConfig.getAuthentication());
+        ConfigurationLogger.log(proxyConfig.getProps());
+    }
+    
     private static void initProxySchemaContexts(final Map<String, Map<String, DataSourceParameter>> schemaDataSources, final Map<String, Collection<RuleConfiguration>> schemaRules,
-                                                final Authentication authentication, final Properties properties, final ProxyConfigurationConverter converter) throws SQLException {
+                                                final Authentication authentication, final Properties properties) throws SQLException {
         // TODO Consider loading from configuration.
         DatabaseType databaseType = schemaDataSources.isEmpty() ? new MySQLDatabaseType()
                 : DatabaseTypes.getActualDatabaseType(
                 JDBCDriverURLRecognizerEngine.getJDBCDriverURLRecognizer(schemaDataSources.values().iterator().next().values().iterator().next().getUrl()).getDatabaseType());
         SchemaContextsBuilder schemaContextsBuilder =
                 new SchemaContextsBuilder(createDataSourcesMap(schemaDataSources), schemaDataSources, authentication, databaseType, schemaRules, properties);
-        ProxySchemaContexts.getInstance().init(converter.contextsAware(schemaContextsBuilder));
+        ProxySchemaContexts.getInstance().init(createSchemaContextsAware(schemaContextsBuilder));
     }
     
     private static Map<String, Map<String, DataSource>> createDataSourcesMap(final Map<String, Map<String, DataSourceParameter>> schemaDataSources) {
@@ -135,6 +138,10 @@ public final class Bootstrap {
         return result;
     }
     
+    private static SchemaContextsAware createSchemaContextsAware(final SchemaContextsBuilder schemaContextsBuilder) throws SQLException {
+        return null == OrchestrationFacade.getInstance() ? schemaContextsBuilder.build() : new ProxyOrchestrationSchemaContexts(schemaContextsBuilder.build());
+    }
+    
     private static void initControlPanelFacade(final MetricsConfiguration metricsConfiguration, final ClusterConfiguration clusterConfiguration) {
         List<FacadeConfiguration> facadeConfigurations = new LinkedList<>();
         if (null != metricsConfiguration && metricsConfiguration.getEnable()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationConfigurationConverter.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationBootstrap.java
similarity index 62%
rename from shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationConfigurationConverter.java
rename to shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationBootstrap.java
index 8708a2a..cef5668 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationConfigurationConverter.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/orchestration/OrchestrationBootstrap.java
@@ -17,70 +17,56 @@
 
 package org.apache.shardingsphere.proxy.orchestration;
 
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration;
 import org.apache.shardingsphere.cluster.configuration.swapper.ClusterConfigurationYamlSwapper;
 import org.apache.shardingsphere.infra.auth.Authentication;
 import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
 import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.kernel.context.SchemaContextsAware;
-import org.apache.shardingsphere.kernel.context.SchemaContextsBuilder;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
 import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
+import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
 import org.apache.shardingsphere.metrics.configuration.swapper.MetricsConfigurationYamlSwapper;
-import org.apache.shardingsphere.orchestration.core.facade.OrchestrationFacade;
-import org.apache.shardingsphere.orchestration.core.common.yaml.config.YamlOrchestrationConfiguration;
 import org.apache.shardingsphere.orchestration.core.common.yaml.swapper.OrchestrationConfigurationYamlSwapper;
+import org.apache.shardingsphere.orchestration.core.facade.OrchestrationFacade;
 import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
 import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
-import org.apache.shardingsphere.proxy.config.converter.AbstractConfigurationConverter;
 import org.apache.shardingsphere.proxy.config.util.DataSourceConverter;
 import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
 import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
-import org.apache.shardingsphere.proxy.orchestration.schema.ProxyOrchestrationSchemaContexts;
 
-import java.sql.SQLException;
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.Properties;
-import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
- * Orchestration configuration converter.
+ * Orchestration bootstrap.
  */
-public final class OrchestrationConfigurationConverter extends AbstractConfigurationConverter {
+@RequiredArgsConstructor
+public final class OrchestrationBootstrap {
     
-    private final OrchestrationFacade orchestrationFacade = OrchestrationFacade.getInstance();
+    private final OrchestrationFacade orchestrationFacade;
     
-    @Override
-    public ProxyConfiguration convert(final YamlProxyConfiguration yamlProxyConfiguration) {
-        YamlOrchestrationConfiguration orchestrationConfig = yamlProxyConfiguration.getServerConfiguration().getOrchestration();
-        Set<String> schemaNames = yamlProxyConfiguration.getRuleConfigurations().keySet();
-        ProxyConfiguration result = new ProxyConfiguration();
-        orchestrationFacade.init(new OrchestrationConfigurationYamlSwapper().swapToObject(orchestrationConfig), schemaNames);
-        initOrchestrationConfigurations(yamlProxyConfiguration.getServerConfiguration(), yamlProxyConfiguration.getRuleConfigurations(), orchestrationFacade);
-        Authentication authentication = orchestrationFacade.getConfigCenter().loadAuthentication();
-        Properties properties = orchestrationFacade.getConfigCenter().loadProperties();
-        Map<String, Map<String, DataSourceParameter>> schemaDataSources = getDataSourceParametersMap(orchestrationFacade);
-        Map<String, Collection<RuleConfiguration>> schemaRules = getSchemaRules(orchestrationFacade);
-        ClusterConfiguration clusterConfiguration = orchestrationFacade.getConfigCenter().loadClusterConfiguration();
-        result.setAuthentication(authentication);
-        result.setProps(properties);
-        result.setSchemaDataSources(schemaDataSources);
-        result.setSchemaRules(schemaRules);
-        result.setCluster(clusterConfiguration);
-        result.setMetrics(getMetricsConfiguration(yamlProxyConfiguration.getServerConfiguration().getMetrics()));
-        return result;
+    /**
+     * Initialize orchestration.
+     * 
+     * @param yamlConfig YAML proxy configuration
+     * @return proxy configuration
+     */
+    public ProxyConfiguration init(final YamlProxyConfiguration yamlConfig) {
+        orchestrationFacade.init(new OrchestrationConfigurationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getOrchestration()), yamlConfig.getRuleConfigurations().keySet());
+        initConfigurations(yamlConfig);
+        return loadProxyConfiguration();
     }
     
-    @Override
-    public SchemaContextsAware contextsAware(final SchemaContextsBuilder builder) throws SQLException {
-        return new ProxyOrchestrationSchemaContexts(builder.build());
-    }
-    
-    private void initOrchestrationConfigurations(
-            final YamlProxyServerConfiguration serverConfig, final Map<String, YamlProxyRuleConfiguration> ruleConfigs, final OrchestrationFacade orchestrationFacade) {
+    private void initConfigurations(final YamlProxyConfiguration yamlConfig) {
+        YamlProxyServerConfiguration serverConfig = yamlConfig.getServerConfiguration();
+        Map<String, YamlProxyRuleConfiguration> ruleConfigs = yamlConfig.getRuleConfigurations();
         if (isEmptyLocalConfiguration(serverConfig, ruleConfigs)) {
             orchestrationFacade.onlineInstance();
         } else {
@@ -97,13 +83,28 @@ public final class OrchestrationConfigurationConverter extends AbstractConfigura
     
     private Map<String, Map<String, DataSourceConfiguration>> getDataSourceConfigurationMap(final Map<String, YamlProxyRuleConfiguration> ruleConfigs) {
         Map<String, Map<String, DataSourceConfiguration>> result = new LinkedHashMap<>();
-        for (Map.Entry<String, YamlProxyRuleConfiguration> entry : ruleConfigs.entrySet()) {
+        for (Entry<String, YamlProxyRuleConfiguration> entry : ruleConfigs.entrySet()) {
             result.put(entry.getKey(), DataSourceConverter.getDataSourceConfigurationMap(DataSourceConverter.getDataSourceParameterMap2(entry.getValue().getDataSources())));
         }
         return result;
     }
     
-    private Map<String, Map<String, DataSourceParameter>> getDataSourceParametersMap(final OrchestrationFacade orchestrationFacade) {
+    private Map<String, Collection<RuleConfiguration>> getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration> yamlRuleConfigurations) {
+        YamlRuleConfigurationSwapperEngine swapperEngine = new YamlRuleConfigurationSwapperEngine();
+        return yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules())));
+    }
+    
+    private ProxyConfiguration loadProxyConfiguration() {
+        Map<String, Map<String, DataSourceParameter>> schemaDataSources = loadDataSourceParametersMap();
+        Map<String, Collection<RuleConfiguration>> schemaRules = loadSchemaRules();
+        Authentication authentication = orchestrationFacade.getConfigCenter().loadAuthentication();
+        ClusterConfiguration clusterConfig = orchestrationFacade.getConfigCenter().loadClusterConfiguration();
+        MetricsConfiguration metricsConfig = orchestrationFacade.getConfigCenter().loadMetricsConfiguration();
+        Properties props = orchestrationFacade.getConfigCenter().loadProperties();
+        return new ProxyConfiguration(schemaDataSources, schemaRules, authentication, clusterConfig, metricsConfig, props);
+    }
+    
+    private Map<String, Map<String, DataSourceParameter>> loadDataSourceParametersMap() {
         Map<String, Map<String, DataSourceParameter>> result = new LinkedHashMap<>();
         for (String each : orchestrationFacade.getConfigCenter().getAllSchemaNames()) {
             result.put(each, DataSourceConverter.getDataSourceParameterMap(orchestrationFacade.getConfigCenter().loadDataSourceConfigurations(each)));
@@ -111,18 +112,11 @@ public final class OrchestrationConfigurationConverter extends AbstractConfigura
         return result;
     }
     
-    private Map<String, Collection<RuleConfiguration>> getSchemaRules(final OrchestrationFacade orchestrationFacade) {
+    private Map<String, Collection<RuleConfiguration>> loadSchemaRules() {
         Map<String, Collection<RuleConfiguration>> result = new LinkedHashMap<>();
         for (String each : orchestrationFacade.getConfigCenter().getAllSchemaNames()) {
             result.put(each, orchestrationFacade.getConfigCenter().loadRuleConfigurations(each));
         }
         return result;
     }
-    
-    @Override
-    public void close() {
-        if (null != orchestrationFacade) {
-            orchestrationFacade.close();
-        }
-    }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
index 9596000..ee4ab29 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
@@ -18,14 +18,13 @@
 package org.apache.shardingsphere.proxy.config;
 
 import lombok.Getter;
-import lombok.Setter;
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration;
 import org.apache.shardingsphere.infra.auth.Authentication;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
 import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
 
-import java.io.Serializable;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
@@ -33,21 +32,19 @@ import java.util.Properties;
 /**
  * Proxy configuration.
  */
+@RequiredArgsConstructor
 @Getter
-@Setter
-public final class ProxyConfiguration implements Serializable {
+public final class ProxyConfiguration {
     
-    private static final long serialVersionUID = 2258701685899056191L;
+    private final Map<String, Map<String, DataSourceParameter>> schemaDataSources;
     
-    private Authentication authentication;
+    private final Map<String, Collection<RuleConfiguration>> schemaRules;
     
-    private Properties props;
+    private final Authentication authentication;
     
-    private Map<String, Map<String, DataSourceParameter>> schemaDataSources;
+    private final ClusterConfiguration cluster;
     
-    private Map<String, Collection<RuleConfiguration>> schemaRules;
+    private final MetricsConfiguration metrics;
     
-    private MetricsConfiguration metrics;
-    
-    private ClusterConfiguration cluster;
+    private final Properties props;
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/AbstractConfigurationConverter.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/AbstractConfigurationConverter.java
deleted file mode 100644
index 436f9ec..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/AbstractConfigurationConverter.java
+++ /dev/null
@@ -1,69 +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.proxy.config.converter;
-
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
-import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
-import org.apache.shardingsphere.metrics.configuration.swapper.MetricsConfigurationYamlSwapper;
-import org.apache.shardingsphere.metrics.configuration.yaml.YamlMetricsConfiguration;
-import org.apache.shardingsphere.proxy.config.util.DataSourceConverter;
-import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- * Abstract configuration converter.
- */
-public abstract class AbstractConfigurationConverter implements ProxyConfigurationConverter {
-    
-    /**
-     * Get rule configurations.
-     *
-     * @param localRuleConfigs rule configs for YAML
-     * @return rule configurations
-     */
-    protected Map<String, Collection<RuleConfiguration>> getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration> localRuleConfigs) {
-        YamlRuleConfigurationSwapperEngine swapperEngine = new YamlRuleConfigurationSwapperEngine();
-        return localRuleConfigs.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules())));
-    }
-    
-    /**
-     * Get data source parameters map.
-     *
-     * @param localRuleConfigs rule configs for YAML
-     * @return data source parameters map
-     */
-    protected Map<String, Map<String, DataSourceParameter>> getDataSourceParametersMap(final Map<String, YamlProxyRuleConfiguration> localRuleConfigs) {
-        return localRuleConfigs.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> DataSourceConverter.getDataSourceParameterMap2(entry.getValue().getDataSources())));
-    }
-    
-    /**
-     * Get metrics configuration.
-     *
-     * @param yamlMetricsConfiguration metrics configuration for YAML
-     * @return metrics configuration
-     */
-    protected MetricsConfiguration getMetricsConfiguration(final YamlMetricsConfiguration yamlMetricsConfiguration) {
-        return Optional.ofNullable(yamlMetricsConfiguration).map(new MetricsConfigurationYamlSwapper()::swapToObject).orElse(null);
-    }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/DefaultConfigurationConverter.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/DefaultConfigurationConverter.java
deleted file mode 100644
index 71d575a..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/DefaultConfigurationConverter.java
+++ /dev/null
@@ -1,69 +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.proxy.config.converter;
-
-import org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration;
-import org.apache.shardingsphere.cluster.configuration.swapper.ClusterConfigurationYamlSwapper;
-import org.apache.shardingsphere.cluster.configuration.yaml.YamlClusterConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.kernel.context.SchemaContextsAware;
-import org.apache.shardingsphere.kernel.context.SchemaContextsBuilder;
-import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
-import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
-import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Default configuration converter.
- */
-public final class DefaultConfigurationConverter extends AbstractConfigurationConverter {
-    
-    @Override
-    public ProxyConfiguration convert(final YamlProxyConfiguration yamlProxyConfiguration) {
-        ProxyConfiguration result = new ProxyConfiguration();
-        Authentication authentication = new AuthenticationYamlSwapper().swapToObject(yamlProxyConfiguration.getServerConfiguration().getAuthentication());
-        Map<String, Map<String, DataSourceParameter>> schemaDataSources = getDataSourceParametersMap(yamlProxyConfiguration.getRuleConfigurations());
-        Map<String, Collection<RuleConfiguration>> schemaRules = getRuleConfigurations(yamlProxyConfiguration.getRuleConfigurations());
-        result.setAuthentication(authentication);
-        result.setProps(yamlProxyConfiguration.getServerConfiguration().getProps());
-        result.setSchemaDataSources(schemaDataSources);
-        result.setSchemaRules(schemaRules);
-        result.setCluster(getClusterConfiguration(yamlProxyConfiguration.getServerConfiguration().getCluster()));
-        result.setMetrics(getMetricsConfiguration(yamlProxyConfiguration.getServerConfiguration().getMetrics()));
-        return result;
-    }
-    
-    @Override
-    public SchemaContextsAware contextsAware(final SchemaContextsBuilder builder) throws SQLException {
-        return builder.build();
-    }
-    
-    private ClusterConfiguration getClusterConfiguration(final YamlClusterConfiguration yamlClusterConfiguration) {
-        return Optional.ofNullable(yamlClusterConfiguration).map(new ClusterConfigurationYamlSwapper()::swapToObject).orElse(null);
-    }
-    
-    @Override
-    public void close() {
-    }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverter.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverter.java
deleted file mode 100644
index 2ebd6a9..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverter.java
+++ /dev/null
@@ -1,48 +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.proxy.config.converter;
-
-import org.apache.shardingsphere.kernel.context.SchemaContextsAware;
-import org.apache.shardingsphere.kernel.context.SchemaContextsBuilder;
-import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
-import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
-
-import java.sql.SQLException;
-
-/**
- * Proxy configuration converter.
- */
-public interface ProxyConfigurationConverter extends AutoCloseable {
-    
-    /**
-     * Convert proxy configuration.
-     *
-     * @param yamlProxyConfiguration YAML proxy configuration
-     * @return proxy configuration
-     */
-    ProxyConfiguration convert(YamlProxyConfiguration yamlProxyConfiguration);
-    
-    /**
-     * Build contexts aware.
-     *
-     * @param builder schema contexts builder
-     * @return schema contexts aware
-     * @throws SQLException sql exception
-     */
-    SchemaContextsAware contextsAware(SchemaContextsBuilder builder) throws SQLException;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverterFactory.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverterFactory.java
deleted file mode 100644
index 39c385f..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/converter/ProxyConfigurationConverterFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.config.converter;
-
-import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
-import org.apache.shardingsphere.infra.spi.singleton.SingletonServiceLoader;
-
-import java.util.Optional;
-
-/**
- * Proxy configuration converter factory.
- */
-public final class ProxyConfigurationConverterFactory {
-    
-    /**
-     * Create new proxy configuration converter instances.
-     *
-     * @param enableOrchestration enable orchestration or not
-     * @return proxy configuration converter
-     */
-    public static ProxyConfigurationConverter newInstances(final boolean enableOrchestration) {
-        return enableOrchestration ? loadConverter() : new DefaultConfigurationConverter();
-    }
-    
-    private static ProxyConfigurationConverter loadConverter() {
-        Optional<ProxyConfigurationConverter> configurationConverter = SingletonServiceLoader.getServiceLoader(ProxyConfigurationConverter.class).newServiceInstances();
-        if (!configurationConverter.isPresent()) {
-            throw new ServiceProviderNotFoundException(ProxyConfigurationConverter.class);
-        }
-        return configurationConverter.get();
-    }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameter.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameter.java
index 80c8bfd..8afdf94 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameter.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameter.java
@@ -47,6 +47,6 @@ public final class YamlDataSourceParameter implements YamlConfiguration {
     private int minPoolSize;
     
     private long maintenanceIntervalMilliseconds;
-
+    
     private boolean readOnly;
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
index fe17e61..d000067 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
@@ -34,13 +34,13 @@ import java.util.Properties;
 @Setter
 public final class YamlProxyServerConfiguration implements YamlConfiguration {
     
-    private YamlMetricsConfiguration metrics;
-    
     private YamlAuthenticationConfiguration authentication;
     
     private YamlOrchestrationConfiguration orchestration;
     
     private YamlClusterConfiguration cluster;
     
+    private YamlMetricsConfiguration metrics;
+    
     private Properties props = new Properties();
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
new file mode 100644
index 0000000..78c86d9
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -0,0 +1,79 @@
+/*
+ * 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.proxy.config.yaml.swapper;
+
+import org.apache.shardingsphere.cluster.configuration.config.ClusterConfiguration;
+import org.apache.shardingsphere.cluster.configuration.swapper.ClusterConfigurationYamlSwapper;
+import org.apache.shardingsphere.cluster.configuration.yaml.YamlClusterConfiguration;
+import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
+import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
+import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
+import org.apache.shardingsphere.metrics.configuration.swapper.MetricsConfigurationYamlSwapper;
+import org.apache.shardingsphere.metrics.configuration.yaml.YamlMetricsConfiguration;
+import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
+import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
+import org.apache.shardingsphere.proxy.config.util.DataSourceConverter;
+import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+/**
+ * YAML proxy configuration swapper.
+ */
+public final class YamlProxyConfigurationSwapper {
+    
+    /**
+     * Swap YAML proxy configuration to proxy configuration.
+     * 
+     * @param yamlConfig YAML proxy configuration
+     * @return proxy configuration
+     */
+    public ProxyConfiguration swap(final YamlProxyConfiguration yamlConfig) {
+        Map<String, Map<String, DataSourceParameter>> schemaDataSources = getDataSourceParametersMap(yamlConfig.getRuleConfigurations());
+        Map<String, Collection<RuleConfiguration>> schemaRules = getRuleConfigurations(yamlConfig.getRuleConfigurations());
+        Authentication authentication = new AuthenticationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getAuthentication());
+        ClusterConfiguration clusterConfig = getClusterConfiguration(yamlConfig.getServerConfiguration().getCluster());
+        MetricsConfiguration metricsConfig = getMetricsConfiguration(yamlConfig.getServerConfiguration().getMetrics());
+        Properties props = yamlConfig.getServerConfiguration().getProps();
+        return new ProxyConfiguration(schemaDataSources, schemaRules, authentication, clusterConfig, metricsConfig, props);
+    }
+    
+    private Map<String, Collection<RuleConfiguration>> getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration> yamlRuleConfigurations) {
+        YamlRuleConfigurationSwapperEngine swapperEngine = new YamlRuleConfigurationSwapperEngine();
+        return yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules())));
+    }
+    
+    private Map<String, Map<String, DataSourceParameter>> getDataSourceParametersMap(final Map<String, YamlProxyRuleConfiguration> yamlRuleConfigurations) {
+        return yamlRuleConfigurations.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> DataSourceConverter.getDataSourceParameterMap2(entry.getValue().getDataSources())));
+    }
+    
+    private ClusterConfiguration getClusterConfiguration(final YamlClusterConfiguration yamlClusterConfiguration) {
+        return Optional.ofNullable(yamlClusterConfiguration).map(new ClusterConfigurationYamlSwapper()::swapToObject).orElse(null);
+    }
+    
+    private MetricsConfiguration getMetricsConfiguration(final YamlMetricsConfiguration yamlMetricsConfiguration) {
+        return Optional.ofNullable(yamlMetricsConfiguration).map(new MetricsConfigurationYamlSwapper()::swapToObject).orElse(null);
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverter b/shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverter
deleted file mode 100644
index d10cd19..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-orchestration/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverter
+++ /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.proxy.orchestration.OrchestrationConfigurationConverter