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 2021/08/22 03:39:45 UTC

[shardingsphere] branch master updated: Add default mode creation to ModeBuilderEngine (#11938)

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 4005fc6  Add default mode creation to ModeBuilderEngine (#11938)
4005fc6 is described below

commit 4005fc6d38114afa51a0a33d4a1c6b47bee27dc3
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Aug 22 11:39:11 2021 +0800

    Add default mode creation to ModeBuilderEngine (#11938)
    
    * Remove useless GovernanceOrder
    
    * Refactor LockNotificationEvent
    
    * Refactor LockReleasedEvent
    
    * Refactor BootstrapInitializer
    
    * Add default mode creation to ModeBuilderEngine
    
    * Avoid NPE
---
 .../governance/core/constant/GovernanceOrder.java  | 38 ----------------------
 .../core/lock/event/LockNotificationEvent.java     |  6 ++--
 .../core/lock/event/LockReleasedEvent.java         |  6 ++--
 .../infra/mode/builder/ModeBuilderEngine.java      |  3 +-
 .../api/ShardingSphereDataSourceFactory.java       | 21 +++++-------
 .../core/datasource/ShardingSphereDataSource.java  |  8 +++--
 .../driver/jdbc/adapter/WrapperAdapterTest.java    |  4 +--
 .../datasource/ShardingSphereDataSourceTest.java   |  4 +--
 .../UnsupportedOperationDataSourceTest.java        |  4 +--
 .../org/apache/shardingsphere/proxy/Bootstrap.java |  3 +-
 .../proxy/initializer/BootstrapInitializer.java    |  2 ++
 .../scaling/core/config/ServerConfiguration.java   |  1 +
 .../test/mysql/env/config/SourceConfiguration.java |  3 +-
 13 files changed, 29 insertions(+), 74 deletions(-)

diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/constant/GovernanceOrder.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/constant/GovernanceOrder.java
deleted file mode 100644
index 6906dea..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/constant/GovernanceOrder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.governance.core.constant;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Governance order.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class GovernanceOrder {
-    
-    /**
-     * Governance order.
-     */
-    public static final int ORDER = -999;
-    
-    /**
-     * Algorithm provider encrypt order.
-     */
-    public static final int ALGORITHM_PROVIDER_ORDER = ORDER + 1;
-}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockNotificationEvent.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockNotificationEvent.java
index e53ffbe..e4e6183 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockNotificationEvent.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockNotificationEvent.java
@@ -17,16 +17,16 @@
 
 package org.apache.shardingsphere.governance.core.lock.event;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.governance.core.registry.GovernanceEvent;
 
 /**
  * Lock notification event.
  */
-@AllArgsConstructor
+@RequiredArgsConstructor
 @Getter
 public final class LockNotificationEvent implements GovernanceEvent {
     
-    private String lockName;
+    private final String lockName;
 }
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockReleasedEvent.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockReleasedEvent.java
index ee32cdd..e68e760 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockReleasedEvent.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/event/LockReleasedEvent.java
@@ -17,16 +17,16 @@
 
 package org.apache.shardingsphere.governance.core.lock.event;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.governance.core.registry.GovernanceEvent;
 
 /**
  * Lock released event.
  */
-@AllArgsConstructor
+@RequiredArgsConstructor
 @Getter
 public final class LockReleasedEvent implements GovernanceEvent {
     
-    private String lockName;
+    private final String lockName;
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/mode/builder/ModeBuilderEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/mode/builder/ModeBuilderEngine.java
index 754dd00..d143358 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/mode/builder/ModeBuilderEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/mode/builder/ModeBuilderEngine.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.mode.builder;
 
 import org.apache.shardingsphere.infra.mode.ShardingSphereMode;
 import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
+import org.apache.shardingsphere.infra.mode.impl.memory.MemoryMode;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
 
@@ -40,6 +41,6 @@ public final class ModeBuilderEngine {
      * @return built mode
      */
     public static ShardingSphereMode build(final ModeConfiguration config) {
-        return TypedSPIRegistry.getRegisteredService(ModeBuilder.class, config.getType(), new Properties()).build(config);
+        return null == config ? new MemoryMode() : TypedSPIRegistry.getRegisteredService(ModeBuilder.class, config.getType(), new Properties()).build(config);
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/api/ShardingSphereDataSourceFactory.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/api/ShardingSphereDataSourceFactory.java
index 97f7abb..316dcdc 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/api/ShardingSphereDataSourceFactory.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/api/ShardingSphereDataSourceFactory.java
@@ -74,7 +74,7 @@ public final class ShardingSphereDataSourceFactory {
      */
     public static DataSource createDataSource(final String schemaName, final ModeConfiguration modeConfig, 
                                               final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return new ShardingSphereDataSource(Strings.isNullOrEmpty(schemaName) ? DefaultSchema.LOGIC_NAME : schemaName, getModeConfiguration(modeConfig), dataSourceMap, configs, props);
+        return new ShardingSphereDataSource(Strings.isNullOrEmpty(schemaName) ? DefaultSchema.LOGIC_NAME : schemaName, modeConfig, dataSourceMap, configs, props);
     }
     
     /**
@@ -89,7 +89,7 @@ public final class ShardingSphereDataSourceFactory {
      */
     public static DataSource createDataSource(final ModeConfiguration modeConfig, 
                                               final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(DefaultSchema.LOGIC_NAME, getModeConfiguration(modeConfig), dataSourceMap, configs, props);
+        return createDataSource(DefaultSchema.LOGIC_NAME, modeConfig, dataSourceMap, configs, props);
     }
     
     /**
@@ -105,8 +105,7 @@ public final class ShardingSphereDataSourceFactory {
      */
     public static DataSource createDataSource(final String schemaName, final ModeConfiguration modeConfig, 
                                               final DataSource dataSource, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(schemaName, 
-                getModeConfiguration(modeConfig), Collections.singletonMap(Strings.isNullOrEmpty(schemaName) ? DefaultSchema.LOGIC_NAME : schemaName, dataSource), configs, props);
+        return createDataSource(schemaName, modeConfig, Collections.singletonMap(Strings.isNullOrEmpty(schemaName) ? DefaultSchema.LOGIC_NAME : schemaName, dataSource), configs, props);
     }
     
     /**
@@ -121,7 +120,7 @@ public final class ShardingSphereDataSourceFactory {
      */
     public static DataSource createDataSource(final ModeConfiguration modeConfig, 
                                               final DataSource dataSource, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(getModeConfiguration(modeConfig), Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSource), configs, props);
+        return createDataSource(modeConfig, Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSource), configs, props);
     }
     
     /**
@@ -136,7 +135,7 @@ public final class ShardingSphereDataSourceFactory {
      */
     public static DataSource createDataSource(final String schemaName,
                                               final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(schemaName, getModeConfiguration(null), dataSourceMap, configs, props);
+        return createDataSource(schemaName, null, dataSourceMap, configs, props);
     }
     
     /**
@@ -149,7 +148,7 @@ public final class ShardingSphereDataSourceFactory {
      * @throws SQLException SQL exception
      */
     public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(getModeConfiguration(null), dataSourceMap, configs, props);
+        return createDataSource((ModeConfiguration) null, dataSourceMap, configs, props);
     }
     
     /**
@@ -163,7 +162,7 @@ public final class ShardingSphereDataSourceFactory {
      * @throws SQLException SQL exception
      */
     public static DataSource createDataSource(final String schemaName, final DataSource dataSource, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(schemaName, getModeConfiguration(null), dataSource, configs, props);
+        return createDataSource(schemaName, null, dataSource, configs, props);
     }
     
     /**
@@ -176,10 +175,6 @@ public final class ShardingSphereDataSourceFactory {
      * @throws SQLException SQL exception
      */
     public static DataSource createDataSource(final DataSource dataSource, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(getModeConfiguration(null), dataSource, configs, props);
-    }
-    
-    private static ModeConfiguration getModeConfiguration(final ModeConfiguration modeConfig) {
-        return null == modeConfig ? new ModeConfiguration("Memory", null, true) : modeConfig;
+        return createDataSource((ModeConfiguration) null, dataSource, configs, props);
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 2c59285..c78ed69 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -67,15 +67,17 @@ public final class ShardingSphereDataSource extends AbstractUnsupportedOperation
         contextManager = createContextManager(schemaName, modeConfig, dataSourceMap, ruleConfigs, props);
     }
     
+    @SuppressWarnings({"rawtypes", "unchecked"})
     private ContextManager createContextManager(final String schemaName, final ModeConfiguration modeConfig) throws SQLException {
         ShardingSphereMode mode = ModeBuilderEngine.build(modeConfig);
         Map<String, Map<String, DataSource>> dataSourcesMap = Collections.singletonMap(schemaName, new HashMap<>());
         Map<String, Collection<RuleConfiguration>> schemaRuleConfigs = Collections.singletonMap(schemaName, Collections.emptyList());
         Collection<RuleConfiguration> globalRuleConfigs = Collections.emptyList();
-        ContextManagerBuilder builder = TypedSPIRegistry.getRegisteredService(ContextManagerBuilder.class, modeConfig.getType(), new Properties());
+        ContextManagerBuilder builder = TypedSPIRegistry.getRegisteredService(ContextManagerBuilder.class, null == modeConfig ? "Memory" : modeConfig.getType(), new Properties());
         return builder.build(mode, dataSourcesMap, schemaRuleConfigs, globalRuleConfigs, new Properties(), false);
     }
     
+    @SuppressWarnings({"rawtypes", "unchecked"})
     private ContextManager createContextManager(final String schemaName, final ModeConfiguration modeConfig, final Map<String, DataSource> dataSourceMap,
                                                 final Collection<RuleConfiguration> ruleConfigs, final Properties props) throws SQLException {
         ShardingSphereMode mode = ModeBuilderEngine.build(modeConfig);
@@ -83,8 +85,8 @@ public final class ShardingSphereDataSource extends AbstractUnsupportedOperation
         Map<String, Collection<RuleConfiguration>> schemaRuleConfigs = Collections.singletonMap(
                 schemaName, ruleConfigs.stream().filter(each -> each instanceof SchemaRuleConfiguration).collect(Collectors.toList()));
         Collection<RuleConfiguration> globalRuleConfigs = ruleConfigs.stream().filter(each -> each instanceof GlobalRuleConfiguration).collect(Collectors.toList());
-        ContextManagerBuilder builder = TypedSPIRegistry.getRegisteredService(ContextManagerBuilder.class, modeConfig.getType(), new Properties());
-        return builder.build(mode, dataSourcesMap, schemaRuleConfigs, globalRuleConfigs, props, modeConfig.isOverwrite());
+        ContextManagerBuilder builder = TypedSPIRegistry.getRegisteredService(ContextManagerBuilder.class, null == modeConfig ? "Memory" : modeConfig.getType(), new Properties());
+        return builder.build(mode, dataSourcesMap, schemaRuleConfigs, globalRuleConfigs, props, null == modeConfig || modeConfig.isOverwrite());
     }
     
     @Override
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
index 26b816d..4928717 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.driver.jdbc.adapter;
 import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
-import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,8 +43,7 @@ public final class WrapperAdapterTest {
     
     @Before
     public void setUp() throws SQLException {
-        shardingSphereDataSource = new ShardingSphereDataSource(
-                DefaultSchema.LOGIC_NAME, new ModeConfiguration("Memory", null, true), Collections.emptyMap(), Collections.emptyList(), new Properties());
+        shardingSphereDataSource = new ShardingSphereDataSource(DefaultSchema.LOGIC_NAME, null, Collections.emptyMap(), Collections.emptyList(), new Properties());
     }
     
     @Test
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
index f6262fa..9eb2415 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.transaction.core.TransactionType;
@@ -182,8 +181,7 @@ public final class ShardingSphereDataSourceTest {
     }
     
     private ShardingSphereDataSource createShardingSphereDataSource(final Map<String, DataSource> dataSourceMap) throws SQLException {
-        return new ShardingSphereDataSource(
-                DefaultSchema.LOGIC_NAME, new ModeConfiguration("Memory", null, true), dataSourceMap, Collections.singletonList(createShardingRuleConfig(dataSourceMap)), new Properties());
+        return new ShardingSphereDataSource(DefaultSchema.LOGIC_NAME, null, dataSourceMap, Collections.singletonList(createShardingRuleConfig(dataSourceMap)), new Properties());
     }
     
     private ShardingRuleConfiguration createShardingRuleConfig(final Map<String, DataSource> dataSourceMap) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
index 81ee6cc..c0be948 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.driver.jdbc.unsupported;
 
 import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
-import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -34,8 +33,7 @@ public final class UnsupportedOperationDataSourceTest {
     
     @Before
     public void setUp() throws SQLException {
-        shardingSphereDataSource = new ShardingSphereDataSource(
-                DefaultSchema.LOGIC_NAME, new ModeConfiguration("Memory", null, true), Collections.emptyMap(), Collections.emptyList(), new Properties());
+        shardingSphereDataSource = new ShardingSphereDataSource(DefaultSchema.LOGIC_NAME, null, Collections.emptyMap(), Collections.emptyList(), new Properties());
     }
     
     @Test(expected = SQLFeatureNotSupportedException.class)
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 4fb1b44..5ffcd72 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
@@ -54,7 +54,6 @@ public final class Bootstrap {
     }
     
     private static ModeConfiguration getModeConfiguration(final YamlProxyConfiguration yamlConfig) {
-        return null == yamlConfig.getServerConfiguration().getMode() 
-                ? new ModeConfiguration("Memory", null, true) : new ModeConfigurationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getMode());
+        return null == yamlConfig.getServerConfiguration().getMode() ? null : new ModeConfigurationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getMode());
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index 00cf861..90cb826 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -67,6 +67,7 @@ public final class BootstrapInitializer {
      * @param yamlConfig YAML proxy configuration
      * @throws SQLException SQL exception
      */
+    @SuppressWarnings("unchecked")
     public void init(final YamlProxyConfiguration yamlConfig) throws SQLException {
         ProxyConfiguration proxyConfig = new YamlProxyConfigurationSwapper().swap(yamlConfig);
         ModeConfiguration modeConfig = null == yamlConfig.getServerConfiguration().getMode()
@@ -123,6 +124,7 @@ public final class BootstrapInitializer {
         if (!scalingConfig.isPresent()) {
             return;
         }
+        // TODO decouple "Cluster" to pluggable
         if ("Cluster".equals(modeConfig.getType())) {
             scalingConfig.get().setModeConfiguration(modeConfig);
             ScalingContext.getInstance().init(scalingConfig.get());
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
index 3d319dd..4eb265e 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
@@ -34,5 +34,6 @@ public final class ServerConfiguration {
     
     private int workerThread = 30;
     
+    // TODO try to use ShardingSphereMode to instead of ModeConfiguration
     private ModeConfiguration modeConfiguration;
 }
diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
index 2403096..33f5bfe 100644
--- a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.integration.scaling.test.mysql.env.config;
 import lombok.SneakyThrows;
 import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
-import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
 import org.apache.shardingsphere.infra.yaml.config.swapper.YamlDataSourceConfigurationSwapper;
 import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapperEngine;
@@ -95,7 +94,7 @@ public final class SourceConfiguration {
     public static DataSource createHostDataSource(final Map<String, YamlTableRuleConfiguration> tableRules) {
         ShardingSphereJDBCDataSourceConfiguration configuration = getHostConfiguration(tableRules);
         return new ShardingSphereDataSource(DefaultSchema.LOGIC_NAME, 
-                new ModeConfiguration("Memory", null, true), new YamlDataSourceConfigurationSwapper().swapToDataSources(configuration.getRootConfig().getDataSources()),
+                null, new YamlDataSourceConfigurationSwapper().swapToDataSources(configuration.getRootConfig().getDataSources()),
                 new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configuration.getRootConfig().getRules()), null);
     }
 }