You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/01/16 06:03:02 UTC

[shardingsphere] branch master updated: Rename DataSourceProperties.props to localProperties (#14803)

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

duanzhengqiang 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 1c0a980  Rename DataSourceProperties.props to localProperties (#14803)
1c0a980 is described below

commit 1c0a98076fac1aa699255b029dd76768610a2a09
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jan 16 14:02:11 2022 +0800

    Rename DataSourceProperties.props to localProperties (#14803)
---
 ...hardingRuleAlteredJobConfigurationPreparer.java |  2 +-
 .../datasource/props/DataSourceProperties.java     | 22 +++++++++++-----------
 .../datasource/props/DataSourcePropertiesTest.java | 14 +++++++-------
 .../YamlDataSourcePropertiesSwapperTest.java       |  6 +++---
 .../jdbc/core/connection/ConnectionManager.java    |  2 +-
 ...dingSpherePipelineDataSourcePropertiesTest.java |  4 ++--
 .../impl/DataSourceMetaDataPersistServiceTest.java |  8 ++++----
 .../resource/ResourceSegmentsConverterTest.java    |  2 +-
 ...oxyProxyResourceConfigurationConverterTest.java |  2 +-
 9 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/schedule/ShardingRuleAlteredJobConfigurationPreparer.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/schedule/ShardingRuleAlteredJobConfigurationPreparer.java
index fb768d4..3091587 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/schedule/ShardingRuleAlteredJobConfigurationPreparer.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/schedule/ShardingRuleAlteredJobConfigurationPreparer.java
@@ -139,7 +139,7 @@ public final class ShardingRuleAlteredJobConfigurationPreparer implements RuleAl
                 tableMap.put(dataNode.getTableName(), each.getLogicTableName());
             }
         }
-        DumperConfiguration dumperConfig = createDumperConfig(dataSourceName, dataSourcePropsMap.get(dataSourceName).getProps(), tableMap);
+        DumperConfiguration dumperConfig = createDumperConfig(dataSourceName, dataSourcePropsMap.get(dataSourceName).getLocalProperties(), tableMap);
         ImporterConfiguration importerConfig = createImporterConfig(pipelineConfig, handleConfig, shardingColumnsMap);
         TaskConfiguration taskConfig = new TaskConfiguration(handleConfig, dumperConfig, importerConfig);
         log.info("toTaskConfigs, dataSourceName={}, taskConfig={}", dataSourceName, taskConfig);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
index 3c1eef6..1632966 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
@@ -41,14 +41,14 @@ public final class DataSourceProperties {
     @Getter(AccessLevel.NONE)
     private final Map<String, String> propertySynonyms;
     
-    private final Map<String, Object> props;
+    private final Map<String, Object> localProperties;
     
     private final Properties customPoolProps = new Properties();
     
-    public DataSourceProperties(final String dataSourceClassName, final Map<String, Object> props) {
+    public DataSourceProperties(final String dataSourceClassName, final Map<String, Object> localProperties) {
         this.dataSourceClassName = dataSourceClassName;
         propertySynonyms = DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName).getPropertySynonyms();
-        this.props = getLocalProperties(props);
+        this.localProperties = getLocalProperties(localProperties);
     }
     
     private Map<String, Object> getLocalProperties(final Map<String, Object> props) {
@@ -70,12 +70,12 @@ public final class DataSourceProperties {
      * @return standard properties
      */
     public Map<String, Object> getStandardProperties() {
-        Map<String, Object> result = new LinkedHashMap<>(props);
+        Map<String, Object> result = new LinkedHashMap<>(localProperties);
         for (Entry<String, String> entry : propertySynonyms.entrySet()) {
             String standardPropertyName = entry.getKey();
             String synonymsPropertyName = entry.getValue();
-            if (props.containsKey(synonymsPropertyName)) {
-                result.put(standardPropertyName, props.get(synonymsPropertyName));
+            if (localProperties.containsKey(synonymsPropertyName)) {
+                result.put(standardPropertyName, localProperties.get(synonymsPropertyName));
                 result.remove(synonymsPropertyName);
             }
         }
@@ -89,7 +89,7 @@ public final class DataSourceProperties {
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
     public Map<String, Object> getAllProperties() {
-        Map<String, Object> result = new HashMap<>(props);
+        Map<String, Object> result = new HashMap<>(localProperties);
         result.putAll((Map) customPoolProps);
         return result;
     }
@@ -103,11 +103,11 @@ public final class DataSourceProperties {
         if (!dataSourceClassName.equals(dataSourceProperties.dataSourceClassName)) {
             return false;
         }
-        for (Entry<String, Object> entry : props.entrySet()) {
-            if (!dataSourceProperties.props.containsKey(entry.getKey())) {
+        for (Entry<String, Object> entry : localProperties.entrySet()) {
+            if (!dataSourceProperties.localProperties.containsKey(entry.getKey())) {
                 continue;
             }
-            if (!String.valueOf(entry.getValue()).equals(String.valueOf(dataSourceProperties.props.get(entry.getKey())))) {
+            if (!String.valueOf(entry.getValue()).equals(String.valueOf(dataSourceProperties.localProperties.get(entry.getKey())))) {
                 return false;
             }
         }
@@ -117,7 +117,7 @@ public final class DataSourceProperties {
     @Override
     public int hashCode() {
         StringBuilder stringBuilder = new StringBuilder();
-        for (Entry<String, Object> entry : props.entrySet()) {
+        for (Entry<String, Object> entry : localProperties.entrySet()) {
             stringBuilder.append(entry.getKey()).append(entry.getValue());
         }
         return Objects.hashCode(dataSourceClassName, stringBuilder.toString());
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 c36d05f..131c7ea 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
@@ -102,13 +102,13 @@ public final class DataSourcePropertiesTest {
         actualDataSource.setConnectionInitSqls(Arrays.asList("set names utf8mb4;", "set names utf8;"));
         DataSourceProperties actual = DataSourcePropertiesCreator.create(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"));
-        assertThat(actual.getProps().get("username").toString(), is("root"));
-        assertThat(actual.getProps().get("password").toString(), is("root"));
-        assertNull(actual.getProps().get("loginTimeout"));
-        assertThat(actual.getProps().get("connectionInitSqls"), instanceOf(List.class));
-        List<String> actualConnectionInitSql = (List<String>) actual.getProps().get("connectionInitSqls");
+        assertThat(actual.getLocalProperties().get("driverClassName").toString(), is(MockedDataSource.class.getCanonicalName()));
+        assertThat(actual.getLocalProperties().get("url").toString(), is("jdbc:mock://127.0.0.1/foo_ds"));
+        assertThat(actual.getLocalProperties().get("username").toString(), is("root"));
+        assertThat(actual.getLocalProperties().get("password").toString(), is("root"));
+        assertNull(actual.getLocalProperties().get("loginTimeout"));
+        assertThat(actual.getLocalProperties().get("connectionInitSqls"), instanceOf(List.class));
+        List<String> actualConnectionInitSql = (List<String>) actual.getLocalProperties().get("connectionInitSqls");
         assertThat(actualConnectionInitSql, hasItem("set names utf8mb4;"));
         assertThat(actualConnectionInitSql, hasItem("set names utf8;"));
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
index ea5d85e..8db0194 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
@@ -58,9 +58,9 @@ public final class YamlDataSourcePropertiesSwapperTest {
         yamlConfig.put("username", "root");
         DataSourceProperties actual = swapper.swapToDataSourceProperties(yamlConfig);
         assertThat(actual.getDataSourceClassName(), is(MockedDataSource.class.getCanonicalName()));
-        assertThat(actual.getProps().size(), is(2));
-        assertThat(actual.getProps().get("url").toString(), is("xx:xxx"));
-        assertThat(actual.getProps().get("username").toString(), is("root"));
+        assertThat(actual.getLocalProperties().size(), is(2));
+        assertThat(actual.getLocalProperties().get("url").toString(), is("xx:xxx"));
+        assertThat(actual.getLocalProperties().get("username").toString(), is("root"));
     }
     
     @Test
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
index b3face2..f952d1c 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
@@ -111,7 +111,7 @@ public final class ConnectionManager implements ExecutorJDBCManager, AutoCloseab
     
     private DataSourceProperties createDataSourceProperties(final ComputeNodeInstance instance, final Collection<ShardingSphereUser> users,
                                                             final DataSourceProperties dataSourcePropsSample, final String schema) {
-        Map<String, Object> props = dataSourcePropsSample.getProps();
+        Map<String, Object> props = dataSourcePropsSample.getLocalProperties();
         props.put("jdbcUrl", createJdbcUrl(instance, schema, props));
         ShardingSphereUser user = users.iterator().next();
         props.put("username", user.getGrantee().getUsername());
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/infra/config/datasource/config/impl/ShardingSpherePipelineDataSourcePropertiesTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/infra/config/datasource/config/impl/ShardingSpherePipelineDataSourcePropertiesTest.java
index 1579ccb..bc44647 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/infra/config/datasource/config/impl/ShardingSpherePipelineDataSourcePropertiesTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/infra/config/datasource/config/impl/ShardingSpherePipelineDataSourcePropertiesTest.java
@@ -40,8 +40,8 @@ public final class ShardingSpherePipelineDataSourcePropertiesTest {
         queryProps.setProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
         dataSourceConfig.appendJDBCQueryProperties(queryProps);
         List<DataSourceProperties> actual = new ArrayList<>(getDataSourcePropertiesMap(dataSourceConfig.getRootConfig().getDataSources()).values());
-        assertThat(actual.get(0).getProps().get("url"), is("jdbc:mysql://192.168.0.2:3306/scaling?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true"));
-        assertThat(actual.get(1).getProps().get("url"), is("jdbc:mysql://192.168.0.1:3306/scaling?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true"));
+        assertThat(actual.get(0).getLocalProperties().get("url"), is("jdbc:mysql://192.168.0.2:3306/scaling?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true"));
+        assertThat(actual.get(1).getLocalProperties().get("url"), is("jdbc:mysql://192.168.0.1:3306/scaling?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true"));
     }
     
     private String getDataSourceYaml() {
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 ada0fc6..e59c492 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
@@ -67,10 +67,10 @@ public final class DataSourceMetaDataPersistServiceTest {
     
     private void assertDataSourceProperties(final DataSourceProperties actual, final DataSourceProperties expected) {
         assertThat(actual.getDataSourceClassName(), is(expected.getDataSourceClassName()));
-        assertThat(actual.getProps().get("url"), is(expected.getProps().get("url")));
-        assertThat(actual.getProps().get("username"), is(expected.getProps().get("username")));
-        assertThat(actual.getProps().get("password"), is(expected.getProps().get("password")));
-        assertThat(actual.getProps().get("connectionInitSqls"), is(expected.getProps().get("connectionInitSqls")));
+        assertThat(actual.getLocalProperties().get("url"), is(expected.getLocalProperties().get("url")));
+        assertThat(actual.getLocalProperties().get("username"), is(expected.getLocalProperties().get("username")));
+        assertThat(actual.getLocalProperties().get("password"), is(expected.getLocalProperties().get("password")));
+        assertThat(actual.getLocalProperties().get("connectionInitSqls"), is(expected.getLocalProperties().get("connectionInitSqls")));
     }
     
     @Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverterTest.java
index 70f8ae6..465c760 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverterTest.java
@@ -39,7 +39,7 @@ public final class ResourceSegmentsConverterTest {
         Map<String, DataSourceProperties> actual = ResourceSegmentsConverter.convert(new MySQLDatabaseType(), createDataSourceSegments());
         assertThat(actual.size(), is(2));
         assertTrue(actual.keySet().containsAll(Arrays.asList("ds0", "ds1")));
-        assertThat(actual.values().iterator().next().getProps().get("username"), is("root0"));
+        assertThat(actual.values().iterator().next().getLocalProperties().get("username"), is("root0"));
         assertThat(actual.values().iterator().next().getCustomPoolProps().getProperty("maxPoolSize"), is("30"));
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/config/resource/ProxyProxyResourceConfigurationConverterTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/config/resource/ProxyProxyResourceConfigurationConverterTest.java
index 4e395cc..2300651 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/config/resource/ProxyProxyResourceConfigurationConverterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/config/resource/ProxyProxyResourceConfigurationConverterTest.java
@@ -49,7 +49,7 @@ public final class ProxyProxyResourceConfigurationConverterTest {
     }
     
     private void assertParameter(final DataSourceProperties actual) {
-        Map<String, Object> props = actual.getProps();
+        Map<String, Object> props = actual.getLocalProperties();
         assertThat(props.size(), is(9));
         assertThat(props.get("jdbcUrl"), is("jdbc:mysql://localhost:3306/demo_ds"));
         assertThat(props.get("username"), is("root"));