You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/12/21 07:01:41 UTC

[shardingsphere] branch master updated: #7318, code style refactor (#8699)

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 8a2b122  #7318, code style refactor (#8699)
8a2b122 is described below

commit 8a2b1222db69c09bd2f9da0acd5e33bef2c0949a
Author: Zhang Yonglun <zh...@apache.org>
AuthorDate: Mon Dec 21 15:01:13 2020 +0800

    #7318, code style refactor (#8699)
    
    * #7318, code style refactor
    
    * #7318, for tests
---
 .../ha/api/config/rule/HADataSourceRuleConfiguration.java             | 2 +-
 .../main/java/org/apache/shardingsphere/ha/algorithm/MGRHAType.java   | 2 +-
 .../main/java/org/apache/shardingsphere/ha/rule/HADataSourceRule.java | 4 ++--
 .../ha/yaml/config/rule/YamlHADataSourceRuleConfiguration.java        | 2 +-
 .../yaml/swapper/HARuleAlgorithmProviderConfigurationYamlSwapper.java | 4 ++--
 .../ha/yaml/swapper/HARuleConfigurationYamlSwapper.java               | 4 ++--
 .../shardingsphere/ha/route/engine/impl/HADataSourceRouter.java       | 2 +-
 .../apache/shardingsphere/ha/spring/boot/HASpringBootStarterTest.java | 2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

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 a3b9335..c98a336 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
@@ -39,5 +39,5 @@ public final class HADataSourceRuleConfiguration {
     
     private final String loadBalancerName;
     
-    private final Boolean readWriteSplit;
+    private final boolean readWriteSplit;
 }
diff --git a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/MGRHAType.java b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/MGRHAType.java
index 2e5f36b..5378de1 100644
--- a/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/MGRHAType.java
+++ b/shardingsphere-features/shardingsphere-ha/shardingsphere-ha-common/src/main/java/org/apache/shardingsphere/ha/algorithm/MGRHAType.java
@@ -83,7 +83,7 @@ public final class MGRHAType implements HAType {
     private void checkReplicaMemberCount(final Statement statement) throws SQLException {
         try (ResultSet resultSet = statement.executeQuery(MEMBER_COUNT)) {
             while (resultSet.next()) {
-                if (Integer.parseInt(resultSet.getString(1)) < 1) {
+                if (resultSet.getInt(1) < 1) {
                     throw new ShardingSphereConfigurationException("MGR member count < 1");
                 }
             }
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 b3ce7ef..e03494a 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
@@ -46,7 +46,7 @@ public final class HADataSourceRule {
     
     private final ReplicaLoadBalanceAlgorithm loadBalancer;
     
-    private final Boolean readWriteSplit;
+    private final boolean readWriteSplit;
     
     @Getter(AccessLevel.NONE)
     private final Collection<String> disabledDataSourceNames = new HashSet<>();
@@ -57,7 +57,7 @@ public final class HADataSourceRule {
         primaryDataSourceName = config.getPrimaryDataSourceName();
         replicaDataSourceNames = config.getReplicaDataSourceNames();
         this.loadBalancer = loadBalancer;
-        this.readWriteSplit = config.getReadWriteSplit();
+        this.readWriteSplit = config.isReadWriteSplit();
     }
     
     private void checkConfiguration(final HADataSourceRuleConfiguration config) {
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 56155b6..84f9122 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
@@ -40,7 +40,7 @@ public final class YamlHADataSourceRuleConfiguration implements YamlConfiguratio
     
     private String loadBalancerName;
     
-    private Boolean readWriteSplit;
+    private boolean readWriteSplit;
     
     private Properties props = new Properties();
 }
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 b139b2b..60e725b 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
@@ -54,7 +54,7 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapper
         result.setPrimaryDataSourceName(dataSourceRuleConfig.getPrimaryDataSourceName());
         result.setReplicaDataSourceNames(dataSourceRuleConfig.getReplicaDataSourceNames());
         result.setLoadBalancerName(dataSourceRuleConfig.getLoadBalancerName());
-        result.setReadWriteSplit(dataSourceRuleConfig.getReadWriteSplit());
+        result.setReadWriteSplit(dataSourceRuleConfig.isReadWriteSplit());
         return result;
     }
     
@@ -71,7 +71,7 @@ public final class HARuleAlgorithmProviderConfigurationYamlSwapper
     
     private HADataSourceRuleConfiguration swapToObject(final String name, final YamlHADataSourceRuleConfiguration yamlDataSourceRuleConfig) {
         return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getPrimaryDataSourceName(), yamlDataSourceRuleConfig.getReplicaDataSourceNames(),
-                yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.getReadWriteSplit());
+                yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.isReadWriteSplit());
     }
     
     @Override
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 eeb61fe..115f553 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
@@ -61,7 +61,7 @@ public final class HARuleConfigurationYamlSwapper
         result.setPrimaryDataSourceName(dataSourceRuleConfig.getPrimaryDataSourceName());
         result.setReplicaDataSourceNames(dataSourceRuleConfig.getReplicaDataSourceNames());
         result.setLoadBalancerName(dataSourceRuleConfig.getLoadBalancerName());
-        result.setReadWriteSplit(dataSourceRuleConfig.getReadWriteSplit());
+        result.setReadWriteSplit(dataSourceRuleConfig.isReadWriteSplit());
         return result;
     }
     
@@ -81,7 +81,7 @@ public final class HARuleConfigurationYamlSwapper
     
     private HADataSourceRuleConfiguration swapToObject(final String name, final YamlHADataSourceRuleConfiguration yamlDataSourceRuleConfig) {
         return new HADataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getPrimaryDataSourceName(), yamlDataSourceRuleConfig.getReplicaDataSourceNames(),
-                yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.getReadWriteSplit());
+                yamlDataSourceRuleConfig.getLoadBalancerName(), yamlDataSourceRuleConfig.isReadWriteSplit());
     }
     
     @Override
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 737f482..2061fc4 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
@@ -39,7 +39,7 @@ public final class HADataSourceRouter {
      * @return data source name
      */
     public String route(final SQLStatement sqlStatement) {
-        if (isPrimaryRoute(sqlStatement) || !rule.getReadWriteSplit()) {
+        if (isPrimaryRoute(sqlStatement) || !rule.isReadWriteSplit()) {
             PrimaryVisitedManager.setPrimaryVisited();
             return rule.getPrimaryDataSourceName();
         }
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 a4063cd..0394cf9 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
@@ -57,7 +57,7 @@ public class HASpringBootStarterTest {
         assertThat(dataSourceRuleConfig.getName(), is("pr_ds"));
         assertThat(dataSourceRuleConfig.getPrimaryDataSourceName(), is("primary_ds"));
         assertThat(dataSourceRuleConfig.getLoadBalancerName(), is("random"));
-        assertTrue(dataSourceRuleConfig.getReadWriteSplit());
+        assertTrue(dataSourceRuleConfig.isReadWriteSplit());
         assertThat(dataSourceRuleConfig.getReplicaDataSourceNames().size(), is(2));
         assertTrue(config.getDataSources().contains(dataSourceRuleConfig));
         assertThat(config.getLoadBalanceAlgorithms().size(), is(1));