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 2022/01/14 10:12:20 UTC

[shardingsphere] branch master updated: Add DataSourcePropertiesCreator (#14778)

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 c6008f3  Add DataSourcePropertiesCreator (#14778)
c6008f3 is described below

commit c6008f326079668b0b1a28110918ed3238dde0c2
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Jan 14 18:11:19 2022 +0800

    Add DataSourcePropertiesCreator (#14778)
---
 .../pool/creator/DataSourcePoolCreator.java        | 37 +++--------
 .../pool/creator/DataSourcePoolCreatorUtil.java    |  7 ++-
 .../props/DataSourcePropertiesCreator.java         | 72 ++++++++++++++++++++++
 .../creator/DataSourcePoolCreatorUtilTest.java     |  2 +-
 .../fixture/FixtureDataSourcePoolMetaData.java     | 60 ++++++++++++++++++
 .../impl/DefaultDataSourcePoolCreatorTest.java     | 18 +-----
 .../impl/HikariDataSourcePoolCreatorTest.java      | 28 +--------
 .../DataSourcePropertiesCreatorTest.java}          | 20 ++----
 .../datasource/props/DataSourcePropertiesTest.java |  4 +-
 ...datasource.pool.metadata.DataSourcePoolMetaData | 18 ++++++
 .../persist/MetaDataPersistServiceTest.java        |  2 +-
 .../impl/DataSourceMetaDataPersistServiceTest.java |  6 +-
 .../cluster/ClusterContextManagerBuilder.java      |  2 +-
 .../ClusterContextManagerCoordinatorTest.java      | 12 ++--
 .../StandaloneContextManagerBuilder.java           |  2 +-
 15 files changed, 183 insertions(+), 107 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreator.java
index a514be2..9753ae3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreator.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreator.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropert
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 
 import javax.sql.DataSource;
-import java.util.Map;
 import java.util.Map.Entry;
 
 /**
@@ -36,39 +35,17 @@ public final class DataSourcePoolCreator {
         ShardingSphereServiceLoader.register(DataSourcePoolMetaData.class);
     }
     
-    private final DataSourcePoolMetaData creationMetaData;
+    private final DataSourcePoolMetaData poolMetaData;
     
     public DataSourcePoolCreator(final String dataSourceClassName) {
-        creationMetaData = DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName);
-    }
-    
-    /**
-     * Create data source properties.
-     * 
-     * @param dataSource data source
-     * @return data source properties
-     */
-    public DataSourceProperties createDataSourceProperties(final DataSource dataSource) {
-        DataSourceProperties result = new DataSourceProperties(dataSource.getClass().getName());
-        filterInvalidProperties(result, new DataSourceReflection(dataSource).convertToProperties());
-        return result;
-    }
-    
-    private void filterInvalidProperties(final DataSourceProperties dataSourceProps, final Map<String, Object> reflectionProps) {
-        for (Entry<String, Object> entry : reflectionProps.entrySet()) {
-            String propertyName = entry.getKey();
-            Object propertyValue = entry.getValue();
-            if (isValidProperty(propertyName, propertyValue)) {
-                dataSourceProps.getProps().put(propertyName, propertyValue);
-            }
-        }
+        poolMetaData = DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName);
     }
     
     /**
      * Create data source.
      * 
      * @param dataSourceProps data source properties
-     * @return data source
+     * @return created data source
      */
     public DataSource createDataSource(final DataSourceProperties dataSourceProps) {
         DataSource result = buildDataSource(dataSourceProps.getDataSourceClassName());
@@ -76,7 +53,7 @@ public final class DataSourcePoolCreator {
         DataSourceReflection dataSourceReflection = new DataSourceReflection(result);
         setDefaultFields(dataSourceReflection);
         setConfiguredFields(dataSourceProps, dataSourceReflection);
-        dataSourceReflection.addDefaultDataSourceProperties(creationMetaData.getJdbcUrlPropertiesFieldName(), creationMetaData.getJdbcUrlFieldName());
+        dataSourceReflection.addDefaultDataSourceProperties(poolMetaData.getJdbcUrlPropertiesFieldName(), poolMetaData.getJdbcUrlFieldName());
         return result;
     }
     
@@ -86,13 +63,13 @@ public final class DataSourcePoolCreator {
     }
     
     private void addPropertySynonym(final DataSourceProperties dataSourceProps) {
-        for (Entry<String, String> entry : creationMetaData.getPropertySynonyms().entrySet()) {
+        for (Entry<String, String> entry : poolMetaData.getPropertySynonyms().entrySet()) {
             dataSourceProps.addPropertySynonym(entry.getKey(), entry.getValue());
         }
     }
     
     private void setDefaultFields(final DataSourceReflection dataSourceReflection) {
-        for (Entry<String, Object> entry : creationMetaData.getDefaultProperties().entrySet()) {
+        for (Entry<String, Object> entry : poolMetaData.getDefaultProperties().entrySet()) {
             dataSourceReflection.setField(entry.getKey(), entry.getValue());
         }
     }
@@ -108,6 +85,6 @@ public final class DataSourcePoolCreator {
     }
     
     private boolean isValidProperty(final String key, final Object value) {
-        return !creationMetaData.getInvalidProperties().containsKey(key) || null == value || !value.equals(creationMetaData.getInvalidProperties().get(key));
+        return !poolMetaData.getInvalidProperties().containsKey(key) || null == value || !value.equals(poolMetaData.getInvalidProperties().get(key));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
index 12f26aa..5bb8d45 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.infra.config.datasource.pool.creator;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
+import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
 
 import javax.sql.DataSource;
 import java.util.LinkedHashMap;
@@ -49,8 +50,8 @@ public final class DataSourcePoolCreatorUtil {
      * @param dataSource data source
      * @return data source properties
      */
-    public static DataSourceProperties getDataSourceConfiguration(final DataSource dataSource) {
-        return new DataSourcePoolCreator(dataSource.getClass().getCanonicalName()).createDataSourceProperties(dataSource);
+    public static DataSourceProperties getDataSourceProperties(final DataSource dataSource) {
+        return new DataSourcePropertiesCreator(dataSource.getClass().getCanonicalName()).createDataSourceProperties(dataSource);
     }
     
     /**
@@ -71,6 +72,6 @@ public final class DataSourcePoolCreatorUtil {
      */
     public static Map<String, DataSourceProperties> getDataSourcePropertiesMap(final Map<String, DataSource> dataSourceMap) {
         return dataSourceMap.entrySet().stream().collect(
-                Collectors.toMap(Entry::getKey, entry -> getDataSourceConfiguration(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+                Collectors.toMap(Entry::getKey, entry -> getDataSourceProperties(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
new file mode 100644
index 0000000..461dce6
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
@@ -0,0 +1,72 @@
+/*
+ * 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.infra.config.datasource.props;
+
+import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourceReflection;
+import org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData;
+import org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaDataFactory;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+
+import javax.sql.DataSource;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Data source properties creator.
+ */
+public final class DataSourcePropertiesCreator {
+    
+    static {
+        ShardingSphereServiceLoader.register(DataSourcePoolMetaData.class);
+    }
+    
+    private final DataSourcePoolMetaData poolMetaData;
+    
+    public DataSourcePropertiesCreator(final String dataSourceClassName) {
+        poolMetaData = DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName);
+    }
+    
+    /**
+     * Create data source properties.
+     * 
+     * @param dataSource data source
+     * @return created data source properties
+     */
+    public DataSourceProperties createDataSourceProperties(final DataSource dataSource) {
+        DataSourceProperties result = new DataSourceProperties(dataSource.getClass().getName());
+        result.getProps().putAll(createProperties(dataSource));
+        return result;
+    }
+    
+    private Map<String, Object> createProperties(final DataSource dataSource) {
+        Map<String, Object> result = new LinkedHashMap<>();
+        for (Entry<String, Object> entry : new DataSourceReflection(dataSource).convertToProperties().entrySet()) {
+            String propertyName = entry.getKey();
+            Object propertyValue = entry.getValue();
+            if (isValidProperty(propertyName, propertyValue)) {
+                result.put(propertyName, propertyValue);
+            }
+        }
+        return result;
+    }
+    
+    private boolean isValidProperty(final String key, final Object value) {
+        return !poolMetaData.getInvalidProperties().containsKey(key) || null == value || !value.equals(poolMetaData.getInvalidProperties().get(key));
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
index 2cce6dc..fadc176 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
@@ -60,7 +60,7 @@ public final class DataSourcePoolCreatorUtilTest {
         actualDataSource.setUsername("root");
         actualDataSource.setPassword("root");
         actualDataSource.setLoginTimeout(1);
-        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceConfiguration(actualDataSource);
+        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceProperties(actualDataSource);
         assertThat(actual.getDataSourceClassName(), is(HikariDataSource.class.getName()));
         assertThat(actual.getProps().get("driverClassName").toString(), is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.getProps().get("jdbcUrl").toString(), is("jdbc:mock://127.0.0.1/foo_ds"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java
new file mode 100644
index 0000000..3ba33cf
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java
@@ -0,0 +1,60 @@
+/*
+ * 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.infra.config.datasource.pool.metadata.fixture;
+
+import org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData;
+import org.apache.shardingsphere.test.mock.MockedDataSource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class FixtureDataSourcePoolMetaData implements DataSourcePoolMetaData {
+    
+    @Override
+    public Map<String, Object> getDefaultProperties() {
+        return null;
+    }
+    
+    @Override
+    public Map<String, Object> getInvalidProperties() {
+        Map<String, Object> result = new HashMap<>(2, 1);
+        result.put("minimumIdle", -1);
+        result.put("maximumPoolSize", -1);
+        return result;
+    }
+    
+    @Override
+    public Map<String, String> getPropertySynonyms() {
+        return null;
+    }
+    
+    @Override
+    public String getJdbcUrlFieldName() {
+        return null;
+    }
+    
+    @Override
+    public String getJdbcUrlPropertiesFieldName() {
+        return null;
+    }
+    
+    @Override
+    public String getType() {
+        return MockedDataSource.class.getCanonicalName();
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
index 2558259..e867a26 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
@@ -17,33 +17,17 @@
 
 package org.apache.shardingsphere.infra.config.datasource.pool.metadata.impl;
 
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
+import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Test;
 
-import javax.sql.DataSource;
-
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
 public final class DefaultDataSourcePoolCreatorTest {
     
     @Test
-    public void assertCreateDataSourceConfiguration() {
-        assertThat(new DataSourcePoolCreator("Default").createDataSourceProperties(createDataSource()), is(createDataSourceProperties()));
-    }
-    
-    private DataSource createDataSource() {
-        MockedDataSource result = new MockedDataSource();
-        result.setDriverClassName("org.h2.Driver");
-        result.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
-        result.setUsername("root");
-        result.setPassword("root");
-        return result;
-    }
-    
-    @Test
     public void assertCreateDataSource() {
         MockedDataSource actual = (MockedDataSource) new DataSourcePoolCreator("Default").createDataSource(createDataSourceProperties());
         assertThat(actual.getDriverClassName(), is("org.h2.Driver"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java
index 0ea1f8a..6ea7474 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.infra.config.datasource.pool.metadata.impl;
 
 import com.zaxxer.hikari.HikariDataSource;
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
+import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Test;
 
@@ -30,37 +30,11 @@ import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 
 public final class HikariDataSourcePoolCreatorTest {
     
     @Test
-    public void assertCreateDataSourcePropertiesWithoutDriverClassName() {
-        HikariDataSource dataSource = new HikariDataSource();
-        dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1/foo_ds");
-        dataSource.setUsername("root");
-        dataSource.setPassword("root");
-        DataSourceProperties dataSourceProps = new DataSourcePoolCreator(HikariDataSource.class.getCanonicalName()).createDataSourceProperties(dataSource);
-        Map<String, Object> props = dataSourceProps.getProps();
-        assertFalse(props.containsKey("driverClassName") && null == props.get("driverClassName"));
-    }
-    
-    @Test
-    public void assertCreateDataSourceProperties() {
-        DataSourcePoolCreator dataSourcePoolCreator = new DataSourcePoolCreator(HikariDataSource.class.getCanonicalName());
-        DataSourceProperties dataSourceProps = dataSourcePoolCreator.createDataSourceProperties(dataSourcePoolCreator.createDataSource(createDataSourceProperties()));
-        assertThat(dataSourceProps.getDataSourceClassName(), is("com.zaxxer.hikari.HikariDataSource"));
-        assertThat(dataSourceProps.getProps().get("jdbcUrl"), is("jdbc:mysql://127.0.0.1/foo_ds"));
-        assertThat(dataSourceProps.getProps().get("driverClassName"), is(MockedDataSource.class.getCanonicalName()));
-        assertThat(dataSourceProps.getProps().get("username"), is("root"));
-        assertThat(dataSourceProps.getProps().get("password"), is("root"));
-        assertThat(dataSourceProps.getProps().get("maximumPoolSize"), is(10));
-        assertThat(dataSourceProps.getProps().get("minimumIdle"), is(1));
-        assertDataSourceProperties((Properties) dataSourceProps.getProps().get("dataSourceProperties"));
-    }
-    
-    @Test
     public void assertCreateDataSource() {
         DataSourcePoolCreator dataSourcePoolCreator = new DataSourcePoolCreator(HikariDataSource.class.getCanonicalName());
         DataSource dataSource = dataSourcePoolCreator.createDataSource(createDataSourceProperties());
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
similarity index 65%
copy from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
index 2558259..5b397e5 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
@@ -15,10 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.config.datasource.pool.metadata.impl;
+package org.apache.shardingsphere.infra.config.datasource.props;
 
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Test;
 
@@ -27,11 +25,11 @@ import javax.sql.DataSource;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
-public final class DefaultDataSourcePoolCreatorTest {
+public final class DataSourcePropertiesCreatorTest {
     
     @Test
-    public void assertCreateDataSourceConfiguration() {
-        assertThat(new DataSourcePoolCreator("Default").createDataSourceProperties(createDataSource()), is(createDataSourceProperties()));
+    public void assertCreateDataSourceProperties() {
+        assertThat(new DataSourcePropertiesCreator("Default").createDataSourceProperties(createDataSource()), is(createDataSourceProperties()));
     }
     
     private DataSource createDataSource() {
@@ -43,21 +41,13 @@ public final class DefaultDataSourcePoolCreatorTest {
         return result;
     }
     
-    @Test
-    public void assertCreateDataSource() {
-        MockedDataSource actual = (MockedDataSource) new DataSourcePoolCreator("Default").createDataSource(createDataSourceProperties());
-        assertThat(actual.getDriverClassName(), is("org.h2.Driver"));
-        assertThat(actual.getUrl(), is("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL"));
-        assertThat(actual.getUsername(), is("root"));
-        assertThat(actual.getPassword(), is("root"));
-    }
-    
     private DataSourceProperties createDataSourceProperties() {
         DataSourceProperties result = new DataSourceProperties(MockedDataSource.class.getCanonicalName());
         result.getProps().put("driverClassName", "org.h2.Driver");
         result.getProps().put("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
         result.getProps().put("username", "root");
         result.getProps().put("password", "root");
+        result.getProps().put("maximumPoolSize", "-1");
         return result;
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
index b5605c4..b5fb188 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
@@ -53,7 +53,7 @@ public final class DataSourcePropertiesTest {
         actualDataSource.setJdbcUrl("jdbc:mock://127.0.0.1/foo_ds");
         actualDataSource.setUsername("root");
         actualDataSource.setPassword("root");
-        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceConfiguration(actualDataSource);
+        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceProperties(actualDataSource);
         actual.addPropertySynonym("url", "jdbcUrl");
         actual.addPropertySynonym("user", "username");
         assertThat(actual.getDataSourceClassName(), is(HikariDataSource.class.getName()));
@@ -132,7 +132,7 @@ public final class DataSourcePropertiesTest {
         actualDataSource.setUsername("root");
         actualDataSource.setPassword("root");
         actualDataSource.setConnectionInitSqls(Arrays.asList("set names utf8mb4;", "set names utf8;"));
-        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceConfiguration(actualDataSource);
+        DataSourceProperties actual = DataSourcePoolCreatorUtil.getDataSourceProperties(actualDataSource);
         assertThat(actual.getDataSourceClassName(), is(BasicDataSource.class.getName()));
         assertThat(actual.getProps().get("driverClassName").toString(), is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.getProps().get("url").toString(), is("jdbc:mock://127.0.0.1/foo_ds"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData
new file mode 100644
index 0000000..209599a
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData
@@ -0,0 +1,18 @@
+#
+# 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.infra.config.datasource.pool.metadata.fixture.FixtureDataSourcePoolMetaData
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
index d5fbd0b..b44557c 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
@@ -103,7 +103,7 @@ public final class MetaDataPersistServiceTest {
     
     private Map<String, DataSourceProperties> createDataSourcePropertiesMap() {
         return createDataSourceMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> 
-                DataSourcePoolCreatorUtil.getDataSourceConfiguration(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+                DataSourcePoolCreatorUtil.getDataSourceProperties(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
     }
     
     private Map<String, DataSource> createDataSourceMap() {
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/DataSourceMetaDataPersistServiceTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/DataSourceMetaDataPersistServiceTest.java
index d4c1cec..e922c60 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/DataSourceMetaDataPersistServiceTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/DataSourceMetaDataPersistServiceTest.java
@@ -55,8 +55,8 @@ public final class DataSourceMetaDataPersistServiceTest {
         when(repository.get("/metadata/foo_db/dataSources")).thenReturn(readDataSourceYaml("yaml/persist/data-source.yaml"));
         Map<String, DataSourceProperties> actual = new DataSourcePersistService(repository).load("foo_db");
         assertThat(actual.size(), is(2));
-        assertDataSourceProperties(actual.get("ds_0"), DataSourcePoolCreatorUtil.getDataSourceConfiguration(createDataSource("ds_0")));
-        assertDataSourceProperties(actual.get("ds_1"), DataSourcePoolCreatorUtil.getDataSourceConfiguration(createDataSource("ds_1")));
+        assertDataSourceProperties(actual.get("ds_0"), DataSourcePoolCreatorUtil.getDataSourceProperties(createDataSource("ds_0")));
+        assertDataSourceProperties(actual.get("ds_1"), DataSourcePoolCreatorUtil.getDataSourceProperties(createDataSource("ds_1")));
     }
     
     @SneakyThrows({IOException.class, URISyntaxException.class})
@@ -82,7 +82,7 @@ public final class DataSourceMetaDataPersistServiceTest {
     
     @Test
     public void assertAppend() {
-        new DataSourcePersistService(repository).append("foo_db", Collections.singletonMap("foo_ds", DataSourcePoolCreatorUtil.getDataSourceConfiguration(createDataSource("foo_ds"))));
+        new DataSourcePersistService(repository).append("foo_db", Collections.singletonMap("foo_ds", DataSourcePoolCreatorUtil.getDataSourceProperties(createDataSource("foo_ds"))));
         String expected = readDataSourceYaml("yaml/persist/data-source-foo.yaml");
         verify(repository).persist("/metadata/foo_db/dataSources", expected);
     }
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index c20df7f..2a9de97 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -187,7 +187,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
             for (Entry<String, DataSourceProperties> entry : loadedDataSourcePropertiesMap.entrySet()) {
                 Map<String, DataSource> localDataSources = localDataSourceMaps.get(each.getKey());
                 if (null != localDataSources && null != localDataSources.get(entry.getKey())
-                        && DataSourcePoolCreatorUtil.getDataSourceConfiguration(localDataSources.get(entry.getKey())).equals(entry.getValue())) {
+                        && DataSourcePoolCreatorUtil.getDataSourceProperties(localDataSources.get(entry.getKey())).equals(entry.getValue())) {
                     dataSources.put(entry.getKey(), localDataSources.get(entry.getKey()));
                 } else {
                     dataSources.put(entry.getKey(), DataSourcePoolCreatorUtil.getDataSource(entry.getValue()));
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index e2a649c..76d85f9 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -134,9 +134,9 @@ public final class ClusterContextManagerCoordinatorTest {
     private Map<String, DataSourceProperties> getDataSourcePropertiesMap() {
         MockedDataSource dataSource = new MockedDataSource();
         Map<String, DataSourceProperties> result = new LinkedHashMap<>(3, 1);
-        result.put("primary_ds", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
-        result.put("ds_0", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
-        result.put("ds_1", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
+        result.put("primary_ds", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
+        result.put("ds_0", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
+        result.put("ds_1", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
         return result;
     }
     
@@ -189,9 +189,9 @@ public final class ClusterContextManagerCoordinatorTest {
     private Map<String, DataSourceProperties> getChangedDataSourcePropertiesMap() {
         MockedDataSource dataSource = new MockedDataSource();
         Map<String, DataSourceProperties> result = new LinkedHashMap<>(3, 1);
-        result.put("primary_ds", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
-        result.put("ds_1", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
-        result.put("ds_2", DataSourcePoolCreatorUtil.getDataSourceConfiguration(dataSource));
+        result.put("primary_ds", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
+        result.put("ds_1", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
+        result.put("ds_2", DataSourcePoolCreatorUtil.getDataSourceProperties(dataSource));
         return result;
     }
     
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index 1891428..b37cdab 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -140,7 +140,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
             for (Entry<String, DataSourceProperties> entry : loadDataSourcePropsMap.entrySet()) {
                 Map<String, DataSource> localDataSources = localDataSourcesMap.get(each.getKey());
                 if (null != localDataSources && null != localDataSources.get(entry.getKey())
-                        && DataSourcePoolCreatorUtil.getDataSourceConfiguration(localDataSources.get(entry.getKey())).equals(entry.getValue())) {
+                        && DataSourcePoolCreatorUtil.getDataSourceProperties(localDataSources.get(entry.getKey())).equals(entry.getValue())) {
                     dataSources.put(entry.getKey(), localDataSources.get(entry.getKey()));
                 } else {
                     dataSources.put(entry.getKey(), DataSourcePoolCreatorUtil.getDataSource(entry.getValue()));