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

[shardingsphere] branch master updated: #7318, discover primaryDataSourceName automatically instead of write into rule config (#8901)

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

zhangliang 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 acde716  #7318, discover primaryDataSourceName automatically instead of write into rule config (#8901)
acde716 is described below

commit acde716b52b0e179d5e2ddf7dc022d2704012285
Author: Zhang Yonglun <zh...@apache.org>
AuthorDate: Tue Jan 5 23:07:53 2021 +0800

    #7318, discover primaryDataSourceName automatically instead of write into rule config (#8901)
    
    * #7318, discover primaryDataSourceName automatically instead of write into rule config
---
 .../ha/api/config/HARuleConfiguration.java         |  2 +-
 .../config/rule/HADataSourceRuleConfiguration.java | 10 ++----
 .../org/apache/shardingsphere/ha/spi/HAType.java   |  8 +++++
 .../ha/spi/ReplicaLoadBalanceAlgorithm.java        |  4 +--
 .../RandomReplicaLoadBalanceAlgorithm.java         |  4 +--
 .../RoundRobinReplicaLoadBalanceAlgorithm.java     |  6 ++--
 .../shardingsphere/ha/rule/HADataSourceRule.java   | 17 ++++------
 .../org/apache/shardingsphere/ha/rule/HARule.java  |  4 ++-
 .../ha/rule/biulder/HARuleBuilder.java             |  3 +-
 .../rule/YamlHADataSourceRuleConfiguration.java    |  4 +--
 ...eAlgorithmProviderConfigurationYamlSwapper.java |  5 ++-
 .../swapper/HARuleConfigurationYamlSwapper.java    |  9 +++---
 .../RandomReplicaLoadBalanceAlgorithmTest.java     |  8 ++---
 .../RoundRobinReplicaLoadBalanceAlgorithmTest.java |  8 ++---
 .../ha/fixture/TestHATypeFixture.java              |  5 +++
 .../ha/rule/HADataSourceRuleTest.java              | 27 +++++++---------
 .../apache/shardingsphere/ha/rule/HARuleTest.java  | 15 +++++----
 .../AlgorithmProvidedHARuleBuilderTest.java        |  2 +-
 .../ha/rule/biulder/HARuleBuilderTest.java         |  2 +-
 ...orithmProviderConfigurationYamlSwapperTest.java |  8 ++---
 .../HARuleConfigurationYamlSwapperTest.java        | 16 ++++------
 ...nfigurationsForYamlHARuleConfigurationTest.java |  6 ++--
 .../src/test/resources/yaml/ha-rule.yaml           |  6 ++--
 .../apache/shardingsphere/ha/mgr/MGRHAType.java    | 12 +++-----
 .../ha/route/engine/HASQLRouter.java               |  4 +--
 .../ha/route/engine/impl/HADataSourceRouter.java   |  7 +++--
 .../ha/route/engine/HASQLRouterTest.java           |  2 +-
 .../ha/route/fixture/TestRouteHATypeFixture.java   |  5 +++
 .../ha/spring/boot/HASpringBootStarterTest.java    |  3 +-
 .../src/test/resources/application-ha.properties   |  2 +-
 .../governance/core/config/ConfigCenter.java       | 31 +------------------
 .../governance/core/config/ConfigCenterTest.java   |  9 +++---
 .../resources/yaml/configCenter/data-ha-rule.yaml  | 11 ++++---
 .../src/test/resources/yaml/ha-rule.yaml           | 27 ++++++++--------
 .../event/impl/PrimaryDataSourceUpdateEvent.java   | 36 ----------------------
 .../src/main/resources/conf/config-ha.yaml         | 14 ++++-----
 36 files changed, 133 insertions(+), 209 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/HARuleConfiguration.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/HARuleConfiguration.java
index 235b2bc..b43221a 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/HARuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/HARuleConfiguration.java
@@ -37,5 +37,5 @@ public final class HARuleConfiguration implements RuleConfiguration {
     
     private final Map<String, ShardingSphereAlgorithmConfiguration> loadBalancers;
     
-    private final ShardingSphereAlgorithmConfiguration haType;
+    private final ShardingSphereAlgorithmConfiguration haConfiguration;
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/rule/HADataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/rule/HADataSourceRuleConfiguration.java
index 245ee89..0c7fd1e 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/rule/HADataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/api/config/rule/HADataSourceRuleConfiguration.java
@@ -17,25 +17,21 @@
 
 package org.apache.shardingsphere.ha.api.config.rule;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
-import lombok.Setter;
+import lombok.RequiredArgsConstructor;
 
 import java.util.List;
 
 /**
  * HA data source rule configuration.
  */
-@AllArgsConstructor
+@RequiredArgsConstructor
 @Getter
 public final class HADataSourceRuleConfiguration {
     
     private final String name;
     
-    @Setter
-    private String primaryDataSourceName;
-    
-    private final List<String> replicaDataSourceNames;
+    private final List<String> dataSourceNames;
     
     private final String loadBalancerName;
     
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/HAType.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/HAType.java
index e90804e..a5fdca0 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/HAType.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/HAType.java
@@ -57,4 +57,12 @@ public interface HAType extends TypedSPI {
      * Stop periodical update.
      */
     void stopPeriodicalUpdate();
+    
+    /**
+     * Get primary data source.
+     *
+     * @return primary data source
+     */
+    String getPrimaryDataSource();
+    
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/ReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/ReplicaLoadBalanceAlgorithm.java
index 7345d2a..7a16e27 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/ReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-api/src/main/java/org/apache/shardingsphere/ha/spi/ReplicaLoadBalanceAlgorithm.java
@@ -31,8 +31,8 @@ public interface ReplicaLoadBalanceAlgorithm extends ShardingSphereAlgorithm {
      * 
      * @param name HA logic data source name
      * @param primaryDataSourceName name of primary data sources
-     * @param replicaDataSourceNames names of replica data sources
+     * @param dataSourceNames names of replica data sources
      * @return name of selected data source
      */
-    String getDataSource(String name, String primaryDataSourceName, List<String> replicaDataSourceNames);
+    String getDataSource(String name, String primaryDataSourceName, List<String> dataSourceNames);
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithm.java
index 75d7983..f651cec 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithm.java
@@ -35,8 +35,8 @@ public final class RandomReplicaLoadBalanceAlgorithm implements ReplicaLoadBalan
     private Properties props = new Properties();
     
     @Override
-    public String getDataSource(final String name, final String primaryDataSourceName, final List<String> replicaDataSourceNames) {
-        return replicaDataSourceNames.get(ThreadLocalRandom.current().nextInt(replicaDataSourceNames.size()));
+    public String getDataSource(final String name, final String primaryDataSourceName, final List<String> dataSourceNames) {
+        return dataSourceNames.get(ThreadLocalRandom.current().nextInt(dataSourceNames.size()));
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithm.java
index 9f34660..213721f 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithm.java
@@ -31,11 +31,11 @@ public final class RoundRobinReplicaLoadBalanceAlgorithm implements ReplicaLoadB
     private static final ConcurrentHashMap<String, AtomicInteger> COUNTS = new ConcurrentHashMap<>();
     
     @Override
-    public String getDataSource(final String name, final String primaryDataSourceName, final List<String> replicaDataSourceNames) {
+    public String getDataSource(final String name, final String primaryDataSourceName, final List<String> dataSourceNames) {
         AtomicInteger count = COUNTS.containsKey(name) ? COUNTS.get(name) : new AtomicInteger(0);
         COUNTS.putIfAbsent(name, count);
-        count.compareAndSet(replicaDataSourceNames.size(), 0);
-        return replicaDataSourceNames.get(Math.abs(count.getAndIncrement()) % replicaDataSourceNames.size());
+        count.compareAndSet(dataSourceNames.size(), 0);
+        return dataSourceNames.get(Math.abs(count.getAndIncrement()) % dataSourceNames.size());
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HADataSourceRule.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HADataSourceRule.java
index 8b1f859..5075a56 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HADataSourceRule.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HADataSourceRule.java
@@ -40,9 +40,7 @@ public final class HADataSourceRule {
     
     private final String name;
     
-    private final String primaryDataSourceName;
-    
-    private final List<String> replicaDataSourceNames;
+    private final List<String> dataSourceNames;
     
     private final ReplicaLoadBalanceAlgorithm loadBalancer;
     
@@ -54,16 +52,14 @@ public final class HADataSourceRule {
     public HADataSourceRule(final HADataSourceRuleConfiguration config, final ReplicaLoadBalanceAlgorithm loadBalancer) {
         checkConfiguration(config);
         name = config.getName();
-        primaryDataSourceName = config.getPrimaryDataSourceName();
-        replicaDataSourceNames = config.getReplicaDataSourceNames();
+        dataSourceNames = config.getDataSourceNames();
         this.loadBalancer = loadBalancer;
         this.replicaQuery = config.isReplicaQuery();
     }
     
     private void checkConfiguration(final HADataSourceRuleConfiguration config) {
         Preconditions.checkArgument(!Strings.isNullOrEmpty(config.getName()), "Name is required.");
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(config.getPrimaryDataSourceName()), "Primary data source name is required.");
-        Preconditions.checkArgument(null != config.getReplicaDataSourceNames() && !config.getReplicaDataSourceNames().isEmpty(), "Replica data source names are required.");
+        Preconditions.checkArgument(null != config.getDataSourceNames() && !config.getDataSourceNames().isEmpty(), "Replica data source names are required.");
     }
     
     /**
@@ -71,8 +67,8 @@ public final class HADataSourceRule {
      *
      * @return available replica data source names
      */
-    public List<String> getReplicaDataSourceNames() {
-        return replicaDataSourceNames.stream().filter(each -> !disabledDataSourceNames.contains(each)).collect(Collectors.toList());
+    public List<String> getDataSourceNames() {
+        return dataSourceNames.stream().filter(each -> !disabledDataSourceNames.contains(each)).collect(Collectors.toList());
     }
     
     /**
@@ -97,8 +93,7 @@ public final class HADataSourceRule {
     public Map<String, Collection<String>> getDataSourceMapper() {
         Map<String, Collection<String>> result = new HashMap<>(1, 1);
         Collection<String> actualDataSourceNames = new LinkedList<>();
-        actualDataSourceNames.add(primaryDataSourceName);
-        actualDataSourceNames.addAll(replicaDataSourceNames);
+        actualDataSourceNames.addAll(dataSourceNames);
         result.put(name, actualDataSourceNames);
         return result;
     }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HARule.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HARule.java
index dabd39b..c5c21d7 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HARule.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/HARule.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.ha.rule;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
+import lombok.Getter;
 import org.apache.shardingsphere.ha.spi.HAType;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
@@ -53,6 +54,7 @@ public final class HARule implements DataSourceContainedRule, StatusContainedRul
         ShardingSphereServiceLoader.register(HAType.class);
     }
     
+    @Getter
     private static HAType haType;
     
     private final Map<String, ReplicaLoadBalanceAlgorithm> loadBalancers = new LinkedHashMap<>();
@@ -72,7 +74,7 @@ public final class HARule implements DataSourceContainedRule, StatusContainedRul
             dataSourceRules.put(each.getName(), new HADataSourceRule(each, loadBalanceAlgorithm));
         }
         if (null == haType) {
-            haType = TypedSPIRegistry.getRegisteredService(HAType.class, config.getHaType().getType(), config.getHaType().getProps());
+            haType = TypedSPIRegistry.getRegisteredService(HAType.class, config.getHaConfiguration().getType(), config.getHaConfiguration().getProps());
             haType.updatePrimaryDataSource(dataSourceMap, schemaName);
         } else {
             haType.stopPeriodicalUpdate();
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilder.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilder.java
index 25cabb0..6f44d95 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilder.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilder.java
@@ -47,8 +47,7 @@ public final class HARuleBuilder implements ShardingSphereRuleBuilder<HARule, HA
     public HARule build(final HARuleConfiguration ruleConfig) {
         Set<String> dataSourceSet = new HashSet<>(128, 1);
         for (HADataSourceRuleConfiguration each : ruleConfig.getDataSources()) {
-            dataSourceSet.add(each.getPrimaryDataSourceName());
-            dataSourceSet.addAll(each.getReplicaDataSourceNames());
+            dataSourceSet.addAll(each.getDataSourceNames());
         }
         dataSourceMap.entrySet().removeIf(stringDataSourceEntry -> !dataSourceSet.contains(stringDataSourceEntry.getKey()));
         return new HARule(ruleConfig, databaseType, dataSourceMap, schemaName);
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/config/rule/YamlHADataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/config/rule/YamlHADataSourceRuleConfiguration.java
index e31ca15..4dd4493 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/config/rule/YamlHADataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/config/rule/YamlHADataSourceRuleConfiguration.java
@@ -34,9 +34,7 @@ public final class YamlHADataSourceRuleConfiguration implements YamlConfiguratio
     
     private String name;
     
-    private String primaryDataSourceName;
-    
-    private List<String> replicaDataSourceNames = new ArrayList<>();
+    private List<String> dataSourceNames = new ArrayList<>();
     
     private String loadBalancerName;
     
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapper.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapper.java
index 114c821..8166e7a 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapper.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapper.java
@@ -51,8 +51,7 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapper
     private YamlHADataSourceRuleConfiguration swapToYamlConfiguration(final HADataSourceRuleConfiguration dataSourceRuleConfig) {
         YamlHADataSourceRuleConfiguration result = new YamlHADataSourceRuleConfiguration();
         result.setName(dataSourceRuleConfig.getName());
-        result.setPrimaryDataSourceName(dataSourceRuleConfig.getPrimaryDataSourceName());
-        result.setReplicaDataSourceNames(dataSourceRuleConfig.getReplicaDataSourceNames());
+        result.setDataSourceNames(dataSourceRuleConfig.getDataSourceNames());
         result.setLoadBalancerName(dataSourceRuleConfig.getLoadBalancerName());
         result.setReplicaQuery(dataSourceRuleConfig.isReplicaQuery());
         return result;
@@ -70,7 +69,7 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapper
     }
     
     private HADataSourceRuleConfiguration swapToObject(final String name, final YamlHADataSourceRuleConfiguration yamlDataSourceRuleConfig) {
-        return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getPrimaryDataSourceName(), yamlDataSourceRuleConfig.getReplicaDataSourceNames(),
+        return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(),
                 yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.isReplicaQuery());
     }
     
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapper.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapper.java
index 00717a9..20edbe8 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapper.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapper.java
@@ -49,8 +49,8 @@ public final class HARuleConfigurationYamlSwapper
         if (null != data.getLoadBalancers()) {
             data.getLoadBalancers().forEach((key, value) -> result.getLoadBalancers().put(key, algorithmSwapper.swapToYamlConfiguration(value)));
         }
-        if (null != data.getHaType()) {
-            result.setHaType(algorithmSwapper.swapToYamlConfiguration(data.getHaType()));
+        if (null != data.getHaConfiguration()) {
+            result.setHaType(algorithmSwapper.swapToYamlConfiguration(data.getHaConfiguration()));
         }
         return result;
     }
@@ -58,8 +58,7 @@ public final class HARuleConfigurationYamlSwapper
     private YamlHADataSourceRuleConfiguration swapToYamlConfiguration(final HADataSourceRuleConfiguration dataSourceRuleConfig) {
         YamlHADataSourceRuleConfiguration result = new YamlHADataSourceRuleConfiguration();
         result.setName(dataSourceRuleConfig.getName());
-        result.setPrimaryDataSourceName(dataSourceRuleConfig.getPrimaryDataSourceName());
-        result.setReplicaDataSourceNames(dataSourceRuleConfig.getReplicaDataSourceNames());
+        result.setDataSourceNames(dataSourceRuleConfig.getDataSourceNames());
         result.setLoadBalancerName(dataSourceRuleConfig.getLoadBalancerName());
         result.setReplicaQuery(dataSourceRuleConfig.isReplicaQuery());
         return result;
@@ -80,7 +79,7 @@ public final class HARuleConfigurationYamlSwapper
     }
     
     private HADataSourceRuleConfiguration swapToObject(final String name, final YamlHADataSourceRuleConfiguration yamlDataSourceRuleConfig) {
-        return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getPrimaryDataSourceName(), yamlDataSourceRuleConfig.getReplicaDataSourceNames(),
+        return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(),
                 yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.isReplicaQuery());
     }
     
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithmTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithmTest.java
index f935ed2..68d21b0 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RandomReplicaLoadBalanceAlgorithmTest.java
@@ -33,9 +33,9 @@ public final class RandomReplicaLoadBalanceAlgorithmTest {
         String primaryDataSourceName = "test_primary_ds";
         String replicaDataSourceName1 = "test_replica_ds_1";
         String replicaDataSourceName2 = "test_replica_ds_2";
-        List<String> replicaDataSourceNames = Arrays.asList(replicaDataSourceName1, replicaDataSourceName2);
-        assertTrue(replicaDataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames)));
-        assertTrue(replicaDataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames)));
-        assertTrue(replicaDataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames)));
+        List<String> dataSourceNames = Arrays.asList(replicaDataSourceName1, replicaDataSourceName2);
+        assertTrue(dataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames)));
+        assertTrue(dataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames)));
+        assertTrue(dataSourceNames.contains(randomReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames)));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithmTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithmTest.java
index 3c84cb0..2e8cfcd 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/algorithm/RoundRobinReplicaLoadBalanceAlgorithmTest.java
@@ -34,9 +34,9 @@ public final class RoundRobinReplicaLoadBalanceAlgorithmTest {
         String primaryDataSourceName = "test_primary_ds";
         String replicaDataSourceName1 = "test_replica_ds_1";
         String replicaDataSourceName2 = "test_replica_ds_2";
-        List<String> replicaDataSourceNames = Arrays.asList(replicaDataSourceName1, replicaDataSourceName2);
-        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames), is(replicaDataSourceName1));
-        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames), is(replicaDataSourceName2));
-        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, replicaDataSourceNames), is(replicaDataSourceName1));
+        List<String> dataSourceNames = Arrays.asList(replicaDataSourceName1, replicaDataSourceName2);
+        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames), is(replicaDataSourceName1));
+        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames), is(replicaDataSourceName2));
+        assertThat(roundRobinReplicaLoadBalanceAlgorithm.getDataSource("ds", primaryDataSourceName, dataSourceNames), is(replicaDataSourceName1));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/fixture/TestHATypeFixture.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/fixture/TestHATypeFixture.java
index 644c13f..1bd200a 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/fixture/TestHATypeFixture.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/fixture/TestHATypeFixture.java
@@ -44,6 +44,11 @@ public final class TestHATypeFixture implements HAType {
     }
     
     @Override
+    public String getPrimaryDataSource() {
+        return null;
+    }
+    
+    @Override
     public String getType() {
         return "Test";
     }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HADataSourceRuleTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HADataSourceRuleTest.java
index ee8cde2..58e2ef3 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HADataSourceRuleTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HADataSourceRuleTest.java
@@ -34,56 +34,51 @@ import static org.junit.Assert.assertThat;
 public final class HADataSourceRuleTest {
     
     private final HADataSourceRule haDataSourceRule = new HADataSourceRule(
-            new HADataSourceRuleConfiguration("test_pr", "primary_ds", Arrays.asList("replica_ds_0", "replica_ds_1"), "random", true), new RandomReplicaLoadBalanceAlgorithm());
+            new HADataSourceRuleConfiguration("test_pr", Arrays.asList("replica_ds_0", "replica_ds_1"), "random", true), new RandomReplicaLoadBalanceAlgorithm());
     
     @Test(expected = IllegalArgumentException.class)
     public void assertNewHADataSourceRuleWithoutName() {
-        new HADataSourceRule(new HADataSourceRuleConfiguration("", "primary_ds", Collections.singletonList("replica_ds"), null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
-    }
-    
-    @Test(expected = IllegalArgumentException.class)
-    public void assertNewHADataSourceRuleWithoutPrimaryDataSourceName() {
-        new HADataSourceRule(new HADataSourceRuleConfiguration("ds", "", Collections.singletonList("replica_ds"), null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
+        new HADataSourceRule(new HADataSourceRuleConfiguration("", Collections.singletonList("replica_ds"), null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
     }
     
     @Test(expected = IllegalArgumentException.class)
     public void assertNewHADataSourceRuleWithNullReplicaDataSourceName() {
-        new HADataSourceRule(new HADataSourceRuleConfiguration("ds", "primary_ds", null, null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
+        new HADataSourceRule(new HADataSourceRuleConfiguration("ds", null, null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
     }
     
     @Test(expected = IllegalArgumentException.class)
     public void assertNewHADataSourceRuleWithEmptyReplicaDataSourceName() {
-        new HADataSourceRule(new HADataSourceRuleConfiguration("ds", "primary_ds", Collections.emptyList(), null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
+        new HADataSourceRule(new HADataSourceRuleConfiguration("ds", Collections.emptyList(), null, true), new RoundRobinReplicaLoadBalanceAlgorithm());
     }
     
     @Test
-    public void assertGetReplicaDataSourceNamesWithoutDisabledDataSourceNames() {
-        assertThat(haDataSourceRule.getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+    public void assertGetDataSourceNamesWithoutDisabledDataSourceNames() {
+        assertThat(haDataSourceRule.getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
     }
     
     @Test
-    public void assertGetReplicaDataSourceNamesWithDisabledDataSourceNames() {
+    public void assertGetDataSourceNamesWithDisabledDataSourceNames() {
         haDataSourceRule.updateDisabledDataSourceNames("replica_ds_0", true);
-        assertThat(haDataSourceRule.getReplicaDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
+        assertThat(haDataSourceRule.getDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
     }
     
     @Test
     public void assertUpdateDisabledDataSourceNamesForDisabled() {
         haDataSourceRule.updateDisabledDataSourceNames("replica_ds_0", true);
-        assertThat(haDataSourceRule.getReplicaDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
+        assertThat(haDataSourceRule.getDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
     }
     
     @Test
     public void assertUpdateDisabledDataSourceNamesForEnabled() {
         haDataSourceRule.updateDisabledDataSourceNames("replica_ds_0", true);
         haDataSourceRule.updateDisabledDataSourceNames("replica_ds_0", false);
-        assertThat(haDataSourceRule.getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+        assertThat(haDataSourceRule.getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
     }
     
     @Test
     public void assertGetDataSourceMapper() {
         Map<String, Collection<String>> actual = haDataSourceRule.getDataSourceMapper();
-        Map<String, Collection<String>> expected = ImmutableMap.of("test_pr", Arrays.asList("primary_ds", "replica_ds_0", "replica_ds_1"));
+        Map<String, Collection<String>> expected = ImmutableMap.of("test_pr", Arrays.asList("replica_ds_0", "replica_ds_1"));
         assertThat(actual, is(expected));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HARuleTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HARuleTest.java
index 119868c..1b4d038 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HARuleTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/HARuleTest.java
@@ -61,7 +61,7 @@ public final class HARuleTest {
     
     private HARule createHARule() {
         HADataSourceRuleConfiguration config =
-                new HADataSourceRuleConfiguration("test_pr", "primary_ds", Arrays.asList("replica_ds_0", "replica_ds_1"), "random", true);
+                new HADataSourceRuleConfiguration("test_pr", Arrays.asList("replica_ds_0", "replica_ds_1"), "random", true);
         return new HARule(new HARuleConfiguration(
                 Collections.singleton(config), ImmutableMap.of("random", new ShardingSphereAlgorithmConfiguration("RANDOM", new Properties())),
                 new ShardingSphereAlgorithmConfiguration("Test", new Properties())),
@@ -70,8 +70,7 @@ public final class HARuleTest {
     
     private void assertDataSourceRule(final HADataSourceRule actual) {
         assertThat(actual.getName(), is("test_pr"));
-        assertThat(actual.getPrimaryDataSourceName(), is("primary_ds"));
-        assertThat(actual.getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+        assertThat(actual.getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
         assertThat(actual.getLoadBalancer().getType(), is("RANDOM"));
     }
     
@@ -79,30 +78,30 @@ public final class HARuleTest {
     public void assertUpdateRuleStatusWithNotExistDataSource() {
         HARule haRule = createHARule();
         haRule.updateRuleStatus(new DataSourceNameDisabledEvent("replica_db", true));
-        assertThat(haRule.getSingleDataSourceRule().getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+        assertThat(haRule.getSingleDataSourceRule().getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
     }
     
     @Test
     public void assertUpdateRuleStatus() {
         HARule haRule = createHARule();
         haRule.updateRuleStatus(new DataSourceNameDisabledEvent("replica_ds_0", true));
-        assertThat(haRule.getSingleDataSourceRule().getReplicaDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
+        assertThat(haRule.getSingleDataSourceRule().getDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
     }
     
     @Test
     public void assertUpdateRuleStatusWithEnable() {
         HARule haRule = createHARule();
         haRule.updateRuleStatus(new DataSourceNameDisabledEvent("replica_ds_0", true));
-        assertThat(haRule.getSingleDataSourceRule().getReplicaDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
+        assertThat(haRule.getSingleDataSourceRule().getDataSourceNames(), is(Collections.singletonList("replica_ds_1")));
         haRule.updateRuleStatus(new DataSourceNameDisabledEvent("replica_ds_0", false));
-        assertThat(haRule.getSingleDataSourceRule().getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+        assertThat(haRule.getSingleDataSourceRule().getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
     }
     
     @Test
     public void assertGetDataSourceMapper() {
         HARule haRule = createHARule();
         Map<String, Collection<String>> actual = haRule.getDataSourceMapper();
-        Map<String, Collection<String>> expected = ImmutableMap.of("test_pr", Arrays.asList("primary_ds", "replica_ds_0", "replica_ds_1"));
+        Map<String, Collection<String>> expected = ImmutableMap.of("test_pr", Arrays.asList("replica_ds_0", "replica_ds_1"));
         assertThat(actual, is(expected));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/AlgorithmProvidedHARuleBuilderTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/AlgorithmProvidedHARuleBuilderTest.java
index 008b2bd..7a6d077 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/AlgorithmProvidedHARuleBuilderTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/AlgorithmProvidedHARuleBuilderTest.java
@@ -43,7 +43,7 @@ public final class AlgorithmProvidedHARuleBuilderTest {
     public void assertBuild() {
         AlgorithmProvidedHARuleConfiguration algorithmProvidedRuleConfig = mock(AlgorithmProvidedHARuleConfiguration.class);
         HADataSourceRuleConfiguration ruleConfig = new HADataSourceRuleConfiguration(
-                "name", "primaryDataSourceName", Collections.singletonList("name"), "loadBalancerName", true);
+                "name", Collections.singletonList("name"), "loadBalancerName", true);
         when(algorithmProvidedRuleConfig.getDataSources()).thenReturn(Collections.singletonList(ruleConfig));
         ShardingSphereRuleBuilder builder = OrderedSPIRegistry.getRegisteredServices(
                 Collections.singletonList(algorithmProvidedRuleConfig), ShardingSphereRuleBuilder.class).get(algorithmProvidedRuleConfig);
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilderTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilderTest.java
index 73e0654..858fda2 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilderTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/rule/biulder/HARuleBuilderTest.java
@@ -46,7 +46,7 @@ public final class HARuleBuilderTest {
     public void assertBuild() {
         HARuleConfiguration ruleConfig = mock(HARuleConfiguration.class);
         HADataSourceRuleConfiguration dataSourceRuleConfig = new HADataSourceRuleConfiguration(
-                "name", "primaryDataSourceName", Collections.singletonList("name"), "loadBalancerName", true);
+                "name", Collections.singletonList("name"), "loadBalancerName", true);
         when(ruleConfig.getDataSources()).thenReturn(Collections.singletonList(dataSourceRuleConfig));
         ShardingSphereRuleBuilder builder = OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), ShardingSphereRuleBuilder.class).get(ruleConfig);
         Map<String, DataSource> dataSourceMap = new HashMap<>();
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 470dcfa..7b1cbf0 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -46,9 +46,8 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapperTest {
         assertNotNull(actual.getDataSources());
         assertThat(actual.getDataSources().keySet(), is(Collections.singleton("name")));
         assertThat(actual.getDataSources().get("name").getName(), is("name"));
-        assertThat(actual.getDataSources().get("name").getPrimaryDataSourceName(), is("primaryDataSourceName"));
         assertThat(actual.getDataSources().get("name").getLoadBalancerName(), is("loadBalancerName"));
-        assertThat(actual.getDataSources().get("name").getReplicaDataSourceNames(), is(Collections.singletonList("replicaDataSourceName")));
+        assertThat(actual.getDataSources().get("name").getDataSourceNames(), is(Collections.singletonList("replicaDataSourceName")));
         assertNotNull(actual.getLoadBalancers());
         assertThat(actual.getLoadBalancers().keySet(), is(Collections.singleton("name")));
         assertNotNull(actual.getLoadBalancers().get("name"));
@@ -64,9 +63,8 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapperTest {
         HADataSourceRuleConfiguration ruleConfig = actual.getDataSources().iterator().next();
         assertNotNull(ruleConfig);
         assertThat(ruleConfig.getName(), is("name"));
-        assertThat(ruleConfig.getPrimaryDataSourceName(), is("primaryDataSourceName"));
         assertThat(ruleConfig.getLoadBalancerName(), is("loadBalancerName"));
-        assertThat(ruleConfig.getReplicaDataSourceNames(), is(Collections.singletonList("replicaDataSourceName")));
+        assertThat(ruleConfig.getDataSourceNames(), is(Collections.singletonList("replicaDataSourceName")));
         assertThat(actual.getLoadBalanceAlgorithms(), is(Collections.emptyMap()));
     }
     
@@ -86,7 +84,7 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapperTest {
     }
     
     private YamlHARuleConfiguration createYamlHARuleConfiguration() {
-        HADataSourceRuleConfiguration ruleConfig = new HADataSourceRuleConfiguration("name", "primaryDataSourceName",
+        HADataSourceRuleConfiguration ruleConfig = new HADataSourceRuleConfiguration("name",
                 Collections.singletonList("replicaDataSourceName"), "loadBalancerName", true);
         return swapper.swapToYamlConfiguration(
                 new AlgorithmProvidedHARuleConfiguration(Collections.singletonList(ruleConfig), ImmutableMap.of("name", new RandomReplicaLoadBalanceAlgorithm()),
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapperTest.java
index d693289..1782d31 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/HARuleConfigurationYamlSwapperTest.java
@@ -52,24 +52,22 @@ public final class HARuleConfigurationYamlSwapperTest {
     @Test
     public void assertSwapToYamlWithLoadBalanceAlgorithm() {
         HADataSourceRuleConfiguration dataSourceConfig =
-                new HADataSourceRuleConfiguration("ds", "primary", Collections.singletonList("replica"), "roundRobin", true);
+                new HADataSourceRuleConfiguration("ds", Collections.singletonList("replica"), "roundRobin", true);
         YamlHARuleConfiguration actual = getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(new HARuleConfiguration(
                 Collections.singleton(dataSourceConfig), ImmutableMap.of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties())),
                 mock(ShardingSphereAlgorithmConfiguration.class)));
         assertThat(actual.getDataSources().get("ds").getName(), is("ds"));
-        assertThat(actual.getDataSources().get("ds").getPrimaryDataSourceName(), is("primary"));
-        assertThat(actual.getDataSources().get("ds").getReplicaDataSourceNames(), is(Collections.singletonList("replica")));
+        assertThat(actual.getDataSources().get("ds").getDataSourceNames(), is(Collections.singletonList("replica")));
         assertThat(actual.getDataSources().get("ds").getLoadBalancerName(), is("roundRobin"));
     }
     
     @Test
     public void assertSwapToYamlWithoutLoadBalanceAlgorithm() {
-        HADataSourceRuleConfiguration dataSourceConfig = new HADataSourceRuleConfiguration("ds", "primary", Collections.singletonList("replica"), null, true);
+        HADataSourceRuleConfiguration dataSourceConfig = new HADataSourceRuleConfiguration("ds", Collections.singletonList("replica"), null, true);
         YamlHARuleConfiguration actual = getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(
                 new HARuleConfiguration(Collections.singleton(dataSourceConfig), Collections.emptyMap(), mock(ShardingSphereAlgorithmConfiguration.class)));
         assertThat(actual.getDataSources().get("ds").getName(), is("ds"));
-        assertThat(actual.getDataSources().get("ds").getPrimaryDataSourceName(), is("primary"));
-        assertThat(actual.getDataSources().get("ds").getReplicaDataSourceNames(), is(Collections.singletonList("replica")));
+        assertThat(actual.getDataSources().get("ds").getDataSourceNames(), is(Collections.singletonList("replica")));
         assertNull(actual.getDataSources().get("ds").getLoadBalancerName());
     }
     
@@ -94,8 +92,7 @@ public final class HARuleConfigurationYamlSwapperTest {
         YamlHARuleConfiguration result = new YamlHARuleConfiguration();
         result.getDataSources().put("ha_ds", new YamlHADataSourceRuleConfiguration());
         result.getDataSources().get("ha_ds").setName("ha_ds");
-        result.getDataSources().get("ha_ds").setPrimaryDataSourceName("primary_ds");
-        result.getDataSources().get("ha_ds").setReplicaDataSourceNames(Arrays.asList("replica_ds_0", "replica_ds_1"));
+        result.getDataSources().get("ha_ds").setDataSourceNames(Arrays.asList("replica_ds_0", "replica_ds_1"));
         YamlShardingSphereAlgorithmConfiguration haType = new YamlShardingSphereAlgorithmConfiguration();
         haType.setType("name");
         haType.setProps(new Properties());
@@ -106,8 +103,7 @@ public final class HARuleConfigurationYamlSwapperTest {
     private void assertHARuleConfiguration(final HARuleConfiguration actual) {
         HADataSourceRuleConfiguration group = actual.getDataSources().iterator().next();
         assertThat(group.getName(), is("ha_ds"));
-        assertThat(group.getPrimaryDataSourceName(), is("primary_ds"));
-        assertThat(group.getReplicaDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
+        assertThat(group.getDataSourceNames(), is(Arrays.asList("replica_ds_0", "replica_ds_1")));
     }
     
     @Test
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/YamlRootRuleConfigurationsForYamlHARuleConfigurationTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/YamlRootRuleConfigurationsForYamlHARuleConfigurationTest.java
index 3e49417..8c1cdca 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/YamlRootRuleConfigurationsForYamlHARuleConfigurationTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/java/org/apache/shardingsphere/ha/yaml/swapper/YamlRootRuleConfigurationsForYamlHARuleConfigurationTest.java
@@ -69,14 +69,12 @@ public final class YamlRootRuleConfigurationsForYamlHARuleConfigurationTest {
     }
     
     private void assertHARuleForDs0(final YamlHARuleConfiguration actual) {
-        assertThat(actual.getDataSources().get("ds_0").getPrimaryDataSourceName(), is("primary_ds_0"));
-        assertThat(actual.getDataSources().get("ds_0").getReplicaDataSourceNames(), is(Arrays.asList("primary_ds_0_replica_0", "primary_ds_0_replica_1")));
+        assertThat(actual.getDataSources().get("ds_0").getDataSourceNames(), is(Arrays.asList("primary_ds_0_replica_0", "primary_ds_0_replica_1")));
         assertThat(actual.getDataSources().get("ds_0").getLoadBalancerName(), is("roundRobin"));
     }
     
     private void assertHARuleForDs1(final YamlHARuleConfiguration actual) {
-        assertThat(actual.getDataSources().get("ds_1").getPrimaryDataSourceName(), is("primary_ds_1"));
-        assertThat(actual.getDataSources().get("ds_1").getReplicaDataSourceNames(), is(Arrays.asList("primary_ds_1_replica_0", "primary_ds_1_replica_1")));
+        assertThat(actual.getDataSources().get("ds_1").getDataSourceNames(), is(Arrays.asList("primary_ds_1_replica_0", "primary_ds_1_replica_1")));
         assertThat(actual.getDataSources().get("ds_1").getLoadBalancerName(), is("random"));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/resources/yaml/ha-rule.yaml b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/resources/yaml/ha-rule.yaml
index 8458d50..ec92289 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/resources/yaml/ha-rule.yaml
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/test/resources/yaml/ha-rule.yaml
@@ -51,15 +51,13 @@ rules:
 - !HA
   dataSources:
     ds_0:
-      primaryDataSourceName: primary_ds_0
-      replicaDataSourceNames:
+      dataSourceNames:
         - primary_ds_0_replica_0
         - primary_ds_0_replica_1
       loadBalancerName: roundRobin
       replicaQuery: true
     ds_1:
-      primaryDataSourceName: primary_ds_1
-      replicaDataSourceNames: 
+      dataSourceNames:
         - primary_ds_1_replica_0
         - primary_ds_1_replica_1
       loadBalancerName: random
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-provider/shardingsphere-ha-mgr/src/main/java/org/apache/shardingsphere/ha/mgr/MGRHAType.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-provider/shardingsphere-ha-mgr/src/main/java/org/apache/shardingsphere/ha/mgr/MGRHAType.java
index 212ed01..6065d2e 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-provider/shardingsphere-ha-mgr/src/main/java/org/apache/shardingsphere/ha/mgr/MGRHAType.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-provider/shardingsphere-ha-mgr/src/main/java/org/apache/shardingsphere/ha/mgr/MGRHAType.java
@@ -27,8 +27,6 @@ import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration
 import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
 import org.apache.shardingsphere.ha.spi.HAType;
 import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
-import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceUpdateEvent;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -122,11 +120,6 @@ public final class MGRHAType implements HAType {
         if (newPrimaryDataSource.isEmpty()) {
             return;
         }
-        if (null == oldPrimaryDataSource) {
-            ShardingSphereEventBus.getInstance().post(new PrimaryDataSourceUpdateEvent(schemaName, newPrimaryDataSource, newPrimaryDataSource));
-        } else if (!newPrimaryDataSource.equals(oldPrimaryDataSource)) {
-            ShardingSphereEventBus.getInstance().post(new PrimaryDataSourceUpdateEvent(schemaName, newPrimaryDataSource, oldPrimaryDataSource));
-        }
         oldPrimaryDataSource = newPrimaryDataSource;
     }
     
@@ -186,6 +179,11 @@ public final class MGRHAType implements HAType {
     }
     
     @Override
+    public String getPrimaryDataSource() {
+        return oldPrimaryDataSource;
+    }
+    
+    @Override
     public String getType() {
         return "MGR";
     }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/HASQLRouter.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/HASQLRouter.java
index ce73d30..185cca8 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/HASQLRouter.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/HASQLRouter.java
@@ -43,7 +43,7 @@ public final class HASQLRouter implements SQLRouter<HARule> {
     @Override
     public RouteContext createRouteContext(final LogicSQL logicSQL, final ShardingSphereMetaData metaData, final HARule rule, final ConfigurationProperties props) {
         RouteContext result = new RouteContext();
-        String dataSourceName = new HADataSourceRouter(rule.getSingleDataSourceRule()).route(logicSQL.getSqlStatementContext().getSqlStatement());
+        String dataSourceName = new HADataSourceRouter(rule.getSingleDataSourceRule()).route(logicSQL.getSqlStatementContext().getSqlStatement(), HARule.getHaType().getPrimaryDataSource());
         result.getRouteUnits().add(new RouteUnit(new RouteMapper(DefaultSchema.LOGIC_NAME, dataSourceName), Collections.emptyList()));
         return result;
     }
@@ -58,7 +58,7 @@ public final class HASQLRouter implements SQLRouter<HARule> {
             Optional<HADataSourceRule> dataSourceRule = rule.findDataSourceRule(dataSourceName);
             if (dataSourceRule.isPresent() && dataSourceRule.get().getName().equalsIgnoreCase(each.getDataSourceMapper().getActualName())) {
                 toBeRemoved.add(each);
-                String actualDataSourceName = new HADataSourceRouter(dataSourceRule.get()).route(logicSQL.getSqlStatementContext().getSqlStatement());
+                String actualDataSourceName = new HADataSourceRouter(dataSourceRule.get()).route(logicSQL.getSqlStatementContext().getSqlStatement(), HARule.getHaType().getPrimaryDataSource());
                 toBeAdded.add(new RouteUnit(new RouteMapper(each.getDataSourceMapper().getLogicName(), actualDataSourceName), each.getTableMappers()));
             }
         }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/impl/HADataSourceRouter.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/impl/HADataSourceRouter.java
index 7214f92..3d9bbfc 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/impl/HADataSourceRouter.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/main/java/org/apache/shardingsphere/ha/route/engine/impl/HADataSourceRouter.java
@@ -36,14 +36,15 @@ public final class HADataSourceRouter {
      * Route.
      * 
      * @param sqlStatement SQL statement
+     * @param primaryDataSourceName primary data source name
      * @return data source name
      */
-    public String route(final SQLStatement sqlStatement) {
+    public String route(final SQLStatement sqlStatement, final String primaryDataSourceName) {
         if (isPrimaryRoute(sqlStatement) || !rule.isReplicaQuery()) {
             PrimaryVisitedManager.setPrimaryVisited();
-            return rule.getPrimaryDataSourceName();
+            return primaryDataSourceName;
         }
-        return rule.getLoadBalancer().getDataSource(rule.getName(), rule.getPrimaryDataSourceName(), rule.getReplicaDataSourceNames());
+        return rule.getLoadBalancer().getDataSource(rule.getName(), primaryDataSourceName, rule.getDataSourceNames());
     }
     
     private boolean isPrimaryRoute(final SQLStatement sqlStatement) {
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/engine/HASQLRouterTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/engine/HASQLRouterTest.java
index 413066f..059e312 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/engine/HASQLRouterTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/engine/HASQLRouterTest.java
@@ -84,7 +84,7 @@ public final class HASQLRouterTest {
     @Before
     public void setUp() {
         rule = new HARule(new HARuleConfiguration(Collections.singleton(
-                new HADataSourceRuleConfiguration(DATASOURCE_NAME, PRIMARY_DATASOURCE, Collections.singletonList(REPLICA_DATASOURCE), null, true)),
+                new HADataSourceRuleConfiguration(DATASOURCE_NAME, Collections.singletonList(REPLICA_DATASOURCE), null, true)),
                 Collections.emptyMap(), new ShardingSphereAlgorithmConfiguration("TestRoute", new Properties())), mock(DatabaseType.class),
                 Collections.singletonMap("ds", mock(DataSource.class)), "ha_db");
         sqlRouter = (HASQLRouter) OrderedSPIRegistry.getRegisteredServices(Collections.singleton(rule), SQLRouter.class).get(rule);
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/fixture/TestRouteHATypeFixture.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/fixture/TestRouteHATypeFixture.java
index f04b87c..204454e 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/fixture/TestRouteHATypeFixture.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-route/src/test/java/org/apache/shardingsphere/ha/route/fixture/TestRouteHATypeFixture.java
@@ -45,6 +45,11 @@ public final class TestRouteHATypeFixture implements HAType {
     }
     
     @Override
+    public String getPrimaryDataSource() {
+        return "primary";
+    }
+    
+    @Override
     public String getType() {
         return "TestRoute";
     }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/java/org/apache/shardingsphere/ha/spring/boot/HASpringBootStarterTest.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/java/org/apache/shardingsphere/ha/spring/boot/HASpringBootStarterTest.java
index c4ad0ef..5e84c0d 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/java/org/apache/shardingsphere/ha/spring/boot/HASpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/java/org/apache/shardingsphere/ha/spring/boot/HASpringBootStarterTest.java
@@ -55,10 +55,9 @@ public class HASpringBootStarterTest {
         assertThat(config.getDataSources().size(), is(1));
         HADataSourceRuleConfiguration dataSourceRuleConfig = config.getDataSources().stream().findFirst().get();
         assertThat(dataSourceRuleConfig.getName(), is("pr_ds"));
-        assertThat(dataSourceRuleConfig.getPrimaryDataSourceName(), is("primary_ds"));
         assertThat(dataSourceRuleConfig.getLoadBalancerName(), is("random"));
         assertTrue(dataSourceRuleConfig.isReplicaQuery());
-        assertThat(dataSourceRuleConfig.getReplicaDataSourceNames().size(), is(2));
+        assertThat(dataSourceRuleConfig.getDataSourceNames().size(), is(2));
         assertTrue(config.getDataSources().contains(dataSourceRuleConfig));
         assertThat(config.getLoadBalanceAlgorithms().size(), is(1));
         assertTrue(config.getLoadBalanceAlgorithms().containsKey("random"));
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/resources/application-ha.properties b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/resources/application-ha.properties
index 83930e1..5c7e2aa 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/resources/application-ha.properties
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-spring/shardingsphere-ha-spring-boot-starter/src/test/resources/application-ha.properties
@@ -18,6 +18,6 @@
 spring.shardingsphere.rules.ha.load-balancers.random.type=RANDOM
 
 spring.shardingsphere.rules.ha.data-sources.pr_ds.primary-data-source-name=primary_ds
-spring.shardingsphere.rules.ha.data-sources.pr_ds.replica-data-source-names=replica_ds_0,replica_ds_1
+spring.shardingsphere.rules.ha.data-sources.pr_ds.data-source-names=replica_ds_0,replica_ds_1
 spring.shardingsphere.rules.ha.data-sources.pr_ds.load-balancer-name=random
 spring.shardingsphere.rules.ha.data-sources.pr_ds.replica-query=true
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
index 9537f28..40fc17d 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
@@ -37,7 +37,6 @@ import org.apache.shardingsphere.governance.core.yaml.swapper.DataSourceConfigur
 import org.apache.shardingsphere.governance.core.yaml.swapper.SchemaYamlSwapper;
 import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
 import org.apache.shardingsphere.ha.api.config.HARuleConfiguration;
-import org.apache.shardingsphere.ha.api.config.rule.HADataSourceRuleConfiguration;
 import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
 import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
 import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
@@ -45,7 +44,6 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceUpdateEvent;
 import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
 import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
@@ -162,22 +160,6 @@ public final class ConfigCenter {
     }
     
     /**
-     * Persist new HA rule configurations.
-     *
-     * @param event Data source name update event.
-     */
-    @Subscribe
-    public synchronized void renew(final PrimaryDataSourceUpdateEvent event) {
-        Collection<RuleConfiguration> ruleConfigurations = loadRuleConfigurations(event.getSchemaName());
-        for (RuleConfiguration each : ruleConfigurations) {
-            if (each instanceof HARuleConfiguration) {
-                updateHaDataSourceRuleConfigurations(event, (HARuleConfiguration) each);
-            }
-        }
-        persistRuleConfigurations(event.getSchemaName(), ruleConfigurations);
-    }
-    
-    /**
      * Switch rule configuration.
      * 
      * @param event switch rule configuration event
@@ -193,17 +175,6 @@ public final class ConfigCenter {
                 YamlEngine.unmarshal(configCacheManager.loadCache(node.getRulePath(schemaName), ruleConfigurationCacheId), YamlRootRuleConfigurations.class).getRules());
     }
     
-    private void updateHaDataSourceRuleConfigurations(final PrimaryDataSourceUpdateEvent event, final HARuleConfiguration haRuleConfiguration) {
-        Collection<HADataSourceRuleConfiguration> haDataSourceRuleConfigurations = haRuleConfiguration.getDataSources();
-        for (HADataSourceRuleConfiguration each : haDataSourceRuleConfigurations) {
-            if (each.getPrimaryDataSourceName().equals(event.getNewPrimaryDataSource())) {
-                break;
-            }
-            each.setPrimaryDataSourceName(event.getNewPrimaryDataSource());
-            each.getReplicaDataSourceNames().remove(event.getNewPrimaryDataSource());
-        }
-    }
-    
     private void persistDataSourceConfigurations(final String schemaName, final Map<String, DataSourceConfiguration> dataSourceConfigurations, final boolean isOverwrite) {
         if (!dataSourceConfigurations.isEmpty() && (isOverwrite || !hasDataSourceConfiguration(schemaName))) {
             persistDataSourceConfigurations(schemaName, dataSourceConfigurations);
@@ -288,7 +259,7 @@ public final class ConfigCenter {
                 configs.add(each);
             } else if (each instanceof HARuleConfiguration) {
                 HARuleConfiguration config = (HARuleConfiguration) each;
-                Preconditions.checkState(!config.getHaType().getType().isEmpty(), "No available HA rule configuration in `%s` for governance.", schemaName);
+                Preconditions.checkState(!config.getHaConfiguration().getType().isEmpty(), "No available HA rule configuration in `%s` for governance.", schemaName);
                 configs.add(each);
             }
         }
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
index 5bf5555..bdd225d 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
@@ -393,11 +393,10 @@ public final class ConfigCenterTest {
         Collection<RuleConfiguration> actual = configCenter.loadRuleConfigurations("sharding_db");
         HARuleConfiguration config = (HARuleConfiguration) actual.iterator().next();
         assertThat(config.getDataSources().size(), is(1));
-        assertThat(config.getDataSources().iterator().next().getPrimaryDataSourceName(), is("primary_ds"));
-        assertThat(config.getDataSources().iterator().next().getReplicaDataSourceNames().size(), is(2));
-        assertThat(config.getHaType().getType(), is("MGR"));
-        assertThat(config.getHaType().getProps().getProperty("keepAliveSeconds"), is("5"));
-        assertThat(config.getHaType().getProps().getProperty("groupName"), is("92504d5b-6dec-11e8-91ea-246e9612aaf1"));
+        assertThat(config.getDataSources().iterator().next().getDataSourceNames().size(), is(3));
+        assertThat(config.getHaConfiguration().getType(), is("MGR"));
+        assertThat(config.getHaConfiguration().getProps().getProperty("keepAliveCron"), is("0/5 * * * * ?"));
+        assertThat(config.getHaConfiguration().getProps().getProperty("groupName"), is("92504d5b-6dec-11e8-91ea-246e9612aaf1"));
     }
     
     @Test
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/configCenter/data-ha-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/configCenter/data-ha-rule.yaml
index 9540f33..b54ad1d 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/configCenter/data-ha-rule.yaml
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/configCenter/data-ha-rule.yaml
@@ -19,13 +19,14 @@ rules:
 - !HA
   dataSources:
     pr_ds:
-      primaryDataSourceName: primary_ds
       name: pr_ds
-      replicaDataSourceNames:
-        - replica_ds_0
-        - replica_ds_1
+      dataSourceNames:
+        - ds_0
+        - ds_1
+        - ds_2
   haType:
     type: MGR
     props:
       groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-      keepAliveSeconds: '5'
+      zkServerLists: 'localhost:2181'
+      keepAliveCron: '0/5 * * * * ?'
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/ha-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/ha-rule.yaml
index 9540f33..5bed73a 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/ha-rule.yaml
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/ha-rule.yaml
@@ -16,16 +16,17 @@
 #
 
 rules:
-- !HA
-  dataSources:
-    pr_ds:
-      primaryDataSourceName: primary_ds
-      name: pr_ds
-      replicaDataSourceNames:
-        - replica_ds_0
-        - replica_ds_1
-  haType:
-    type: MGR
-    props:
-      groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-      keepAliveSeconds: '5'
+  - !HA
+    dataSources:
+      pr_ds:
+        name: pr_ds
+        dataSourceNames:
+          - ds_0
+          - ds_1
+          - ds_2
+    haType:
+      type: MGR
+      props:
+        groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+        zkServerLists: 'localhost:2181'
+        keepAliveCron: '0/5 * * * * ?'
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceUpdateEvent.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceUpdateEvent.java
deleted file mode 100644
index fe0475e..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceUpdateEvent.java
+++ /dev/null
@@ -1,36 +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.infra.rule.event.impl;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.RuleChangedEvent;
-
-/**
- * Primary data source update event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class PrimaryDataSourceUpdateEvent implements RuleChangedEvent {
-    
-    private final String schemaName;
-    
-    private final String newPrimaryDataSource;
-    
-    private final String oldPrimaryDataSource;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-ha.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-ha.yaml
index 23feb9c..0320751 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-ha.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-ha.yaml
@@ -75,7 +75,7 @@
 #schemaName: ha_db
 #
 #dataSources:
-#  primary_ds:
+#  ds_0:
 #    url: jdbc:mysql://127.0.0.1:3306/demo_primary_ds?serverTimezone=UTC&useSSL=false
 #    username: root
 #    password:
@@ -85,7 +85,7 @@
 #    maxPoolSize: 50
 #    minPoolSize: 1
 #    maintenanceIntervalMilliseconds: 30000
-#  replica_ds_0:
+#  ds_1:
 #    url: jdbc:mysql://127.0.0.1:3306/demo_replica_ds_0?serverTimezone=UTC&useSSL=false
 #    username: root
 #    password:
@@ -95,7 +95,7 @@
 #    maxPoolSize: 50
 #    minPoolSize: 1
 #    maintenanceIntervalMilliseconds: 30000
-#  replica_ds_1:
+#  ds_2:
 #    url: jdbc:mysql://127.0.0.1:3306/demo_replica_ds_1?serverTimezone=UTC&useSSL=false
 #    username: root
 #    password:
@@ -111,10 +111,10 @@
 #  dataSources:
 #    pr_ds:
 #      name: pr_ds
-#      primaryDataSourceName: primary_ds
-#      replicaDataSourceNames:
-#        - replica_ds_0
-#        - replica_ds_1
+#      dataSourceNames:
+#        - ds_0
+#        - ds_1
+#        - ds_2
 #      replicaQuery: false
 #  haType:
 #    type: MGR