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 32ce404  Remove datasource name of YAML db discovery configuration 
(#10373)
32ce404 is described below

commit 32ce4046630fc97a67c4c066126b13f494c2790b
Author: Haoran Meng <[email protected]>
AuthorDate: Tue May 18 12:43:36 2021 +0800

    Remove datasource name of YAML db discovery configuration (#10373)
    
    Co-authored-by: menghaoranss <[email protected]>
---
 .../resources/conf/config-database-discovery.yaml  | 22 ++++++++++++++--------
 ...tabaseDiscoveryDataSourceRuleConfiguration.java |  4 +---
 ...eAlgorithmProviderConfigurationYamlSwapper.java |  1 -
 ...abaseDiscoveryRuleConfigurationYamlSwapper.java |  1 -
 ...orithmProviderConfigurationYamlSwapperTest.java |  1 -
 ...eDiscoveryRuleConfigurationYamlSwapperTest.java |  5 ++---
 .../resources/yaml/database-discovery-rule.yaml    |  1 -
 .../data-database-discovery-rule.yaml              |  1 -
 .../resources/conf/config-database-discovery.yaml  | 22 ++++++++++++++--------
 9 files changed, 31 insertions(+), 27 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
 
b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
similarity index 91%
copy from 
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
copy to 
shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
index db77cb5..4dac500 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
+++ 
b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
@@ -58,13 +58,20 @@
 #
 #rules:
 #- !DB_DISCOVERY
-#  dataSources:
-#    pr_ds:
-#      name: pr_ds
-#      primaryDataSourceName: primary_ds
-#      replicaDataSourceNames:
-#        - replica_ds_0
-#        - replica_ds_1
+#    dataSources:
+#      pr_ds:
+#        dataSourceNames:
+#          - ds_0
+#          - ds_1
+#          - ds_2
+#        discoveryTypeName: mgr
+#    discoveryTypes:
+#      mgr:
+#        type: MGR
+#        props:
+#          groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+#          zkServerLists: 'localhost:2181'
+#          keepAliveCron: '0/5 * * * * ?'
 
 
######################################################################################################
 #
@@ -110,7 +117,6 @@
 #  - !DB_DISCOVERY
 #    dataSources:
 #      pr_ds:
-#        name: pr_ds
 #        dataSourceNames:
 #          - ds_0
 #          - ds_1
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
index c641bcb..b1e3a81 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
@@ -31,9 +31,7 @@ import java.util.Properties;
 @Getter
 @Setter
 public final class YamlDatabaseDiscoveryDataSourceRuleConfiguration implements 
YamlConfiguration {
-    
-    private String name;
-    
+
     private List<String> dataSourceNames = new ArrayList<>();
     
     private String discoveryTypeName;
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
index ca68bfd..7516fa3 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
@@ -46,7 +46,6 @@ public final class 
DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwappe
     
     private YamlDatabaseDiscoveryDataSourceRuleConfiguration 
swapToYamlConfiguration(final DatabaseDiscoveryDataSourceRuleConfiguration 
dataSourceRuleConfig) {
         YamlDatabaseDiscoveryDataSourceRuleConfiguration result = new 
YamlDatabaseDiscoveryDataSourceRuleConfiguration();
-        result.setName(dataSourceRuleConfig.getName());
         result.setDataSourceNames(dataSourceRuleConfig.getDataSourceNames());
         return result;
     }
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
index 2619169..2290cc5 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
@@ -54,7 +54,6 @@ public final class 
DatabaseDiscoveryRuleConfigurationYamlSwapper
     
     private YamlDatabaseDiscoveryDataSourceRuleConfiguration 
swapToYamlConfiguration(final DatabaseDiscoveryDataSourceRuleConfiguration 
dataSourceRuleConfig) {
         YamlDatabaseDiscoveryDataSourceRuleConfiguration result = new 
YamlDatabaseDiscoveryDataSourceRuleConfiguration();
-        result.setName(dataSourceRuleConfig.getName());
         result.setDataSourceNames(dataSourceRuleConfig.getDataSourceNames());
         
result.setDiscoveryTypeName(dataSourceRuleConfig.getDiscoveryTypeName());
         return result;
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index a343c4a..b80a5f0 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -43,7 +43,6 @@ public final class 
DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwappe
         assertNotNull(actual);
         assertNotNull(actual.getDataSources());
         assertThat(actual.getDataSources().keySet(), 
is(Collections.singleton("name")));
-        assertThat(actual.getDataSources().get("name").getName(), is("name"));
     }
     
     @Test
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
index 81ea2eb..1eb6d18 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/dbdiscovery/common/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
@@ -52,7 +52,7 @@ public final class 
DatabaseDiscoveryRuleConfigurationYamlSwapperTest {
                 new DatabaseDiscoveryDataSourceRuleConfiguration("ds", 
Collections.singletonList("dataSourceName"), "discoveryTypeName");
         YamlDatabaseDiscoveryRuleConfiguration actual = 
getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(new 
DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig),
                 ImmutableMap.of("mgr", new 
ShardingSphereAlgorithmConfiguration("MGR", new Properties()))));
-        assertThat(actual.getDataSources().get("ds").getName(), is("ds"));
+        assertThat(actual.getDataSources().keySet(), 
is(Collections.singleton("ds")));
         assertThat(actual.getDataSources().get("ds").getDataSourceNames(), 
is(Collections.singletonList("dataSourceName")));
     }
     
@@ -61,7 +61,7 @@ public final class 
DatabaseDiscoveryRuleConfigurationYamlSwapperTest {
         DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig = new 
DatabaseDiscoveryDataSourceRuleConfiguration("ds", 
Collections.singletonList("dataSourceName"), "discoveryTypeName");
         YamlDatabaseDiscoveryRuleConfiguration actual = 
getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(
                 new 
DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig), 
Collections.emptyMap()));
-        assertThat(actual.getDataSources().get("ds").getName(), is("ds"));
+        assertThat(actual.getDataSources().keySet(), 
is(Collections.singleton("ds")));
         assertThat(actual.getDataSources().get("ds").getDataSourceNames(), 
is(Collections.singletonList("dataSourceName")));
     }
     
@@ -82,7 +82,6 @@ public final class 
DatabaseDiscoveryRuleConfigurationYamlSwapperTest {
     private YamlDatabaseDiscoveryRuleConfiguration 
createYamlHARuleConfiguration() {
         YamlDatabaseDiscoveryRuleConfiguration result = new 
YamlDatabaseDiscoveryRuleConfiguration();
         result.getDataSources().put("ha_ds", new 
YamlDatabaseDiscoveryDataSourceRuleConfiguration());
-        result.getDataSources().get("ha_ds").setName("ha_ds");
         
result.getDataSources().get("ha_ds").setDataSourceNames(Arrays.asList("ds_0", 
"ds_1"));
         return result;
     }
diff --git 
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
 
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
index 866e857..50ddf3f 100644
--- 
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
+++ 
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
@@ -19,7 +19,6 @@ rules:
   - !DB_DISCOVERY
     dataSources:
       pr_ds:
-        name: pr_ds
         dataSourceNames:
           - ds_0
           - ds_1
diff --git 
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
 
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
index 866e857..50ddf3f 100644
--- 
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
+++ 
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
@@ -19,7 +19,6 @@ rules:
   - !DB_DISCOVERY
     dataSources:
       pr_ds:
-        name: pr_ds
         dataSourceNames:
           - ds_0
           - ds_1
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
index db77cb5..4dac500 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
@@ -58,13 +58,20 @@
 #
 #rules:
 #- !DB_DISCOVERY
-#  dataSources:
-#    pr_ds:
-#      name: pr_ds
-#      primaryDataSourceName: primary_ds
-#      replicaDataSourceNames:
-#        - replica_ds_0
-#        - replica_ds_1
+#    dataSources:
+#      pr_ds:
+#        dataSourceNames:
+#          - ds_0
+#          - ds_1
+#          - ds_2
+#        discoveryTypeName: mgr
+#    discoveryTypes:
+#      mgr:
+#        type: MGR
+#        props:
+#          groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+#          zkServerLists: 'localhost:2181'
+#          keepAliveCron: '0/5 * * * * ?'
 
 
######################################################################################################
 #
@@ -110,7 +117,6 @@
 #  - !DB_DISCOVERY
 #    dataSources:
 #      pr_ds:
-#        name: pr_ds
 #        dataSourceNames:
 #          - ds_0
 #          - ds_1

Reply via email to