You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/24 03:55:52 UTC

[shardingsphere] branch master updated: Change StorageNodeDataSource.replicationDelayMilliseconds from Long to long (#17043)

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 d78d031b167 Change StorageNodeDataSource.replicationDelayMilliseconds from Long to long (#17043)
d78d031b167 is described below

commit d78d031b167d08d108461a8014ec0dfd96b8298f
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Apr 24 11:55:47 2022 +0800

    Change StorageNodeDataSource.replicationDelayMilliseconds from Long to long (#17043)
    
    * Refactor MySQLNormalReplicationMySQLDatabaseDiscoveryType
    
    * Refactor MGRMySQLDatabaseDiscoveryType
    
    * Refactor MGRMySQLDatabaseDiscoveryType
    
    * Change StorageNodeDataSource.replicationDelayMilliseconds from Long to long
---
 .../MySQLNormalReplicationMySQLDatabaseDiscoveryType.java           | 3 ++-
 .../apache/shardingsphere/infra/storage/StorageNodeDataSource.java  | 6 +++---
 .../queryable/ShowReadwriteSplittingReadResourcesHandler.java       | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/replication/MySQLNormalReplicationMySQLDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/replication/MySQLNormalReplicationMySQLD [...]
index 16f98fc900f..88b03079f19 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/replication/MySQLNormalReplicationMySQLDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/replication/MySQLNormalReplicationMySQLDatabaseDiscoveryType.java
@@ -80,7 +80,8 @@ public final class MySQLNormalReplicationMySQLDatabaseDiscoveryType extends Abst
                 Statement statement = connection.createStatement()) {
             long replicationDelayMilliseconds = loadReplicationDelayMilliseconds(statement);
             StorageNodeStatus storageNodeStatus = replicationDelayMilliseconds < Long.parseLong(getProps().getProperty("delay-milliseconds-threshold"))
-                    ? StorageNodeStatus.ENABLED : StorageNodeStatus.DISABLED;
+                    ? StorageNodeStatus.ENABLED
+                    : StorageNodeStatus.DISABLED;
             ShardingSphereEventBus.getInstance().post(
                     new DataSourceDisabledEvent(databaseName, groupName, datasourceName, new StorageNodeDataSource(StorageNodeRole.MEMBER, storageNodeStatus, replicationDelayMilliseconds)));
         } catch (SQLException ex) {
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/storage/StorageNodeDataSource.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/storage/StorageNodeDataSource.java
index a8aa8540604..9abe1ef645a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/storage/StorageNodeDataSource.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/storage/StorageNodeDataSource.java
@@ -33,15 +33,15 @@ public final class StorageNodeDataSource {
     
     private String status;
     
-    private Long replicationDelayMilliseconds;
+    private long replicationDelayMilliseconds;
     
     public StorageNodeDataSource(final StorageNodeRole role, final StorageNodeStatus status) {
         this.role = role.name().toLowerCase();
         this.status = status.name().toLowerCase();
-        replicationDelayMilliseconds = null;
+        replicationDelayMilliseconds = 0L;
     }
     
-    public StorageNodeDataSource(final StorageNodeRole role, final StorageNodeStatus status, final Long replicationDelayMilliseconds) {
+    public StorageNodeDataSource(final StorageNodeRole role, final StorageNodeStatus status, final long replicationDelayMilliseconds) {
         this.role = role.name().toLowerCase();
         this.status = status.name().toLowerCase();
         this.replicationDelayMilliseconds = replicationDelayMilliseconds;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowReadwriteSplittingReadResourcesHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowReadwriteSplittingReadResourcesHandler.java
index 82f8494798d..e2018050edd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowReadwriteSplittingReadResourcesHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowReadwriteSplittingReadResourcesHandler.java
@@ -132,9 +132,9 @@ public final class ShowReadwriteSplittingReadResourcesHandler extends QueryableR
         if (null == storageNodeDataSource) {
             return Arrays.asList(resource, StorageNodeStatus.ENABLED.name().toLowerCase(), "0");
         } else {
-            Long replicationDelayTime = storageNodeDataSource.getReplicationDelayMilliseconds();
+            long replicationDelayMilliseconds = storageNodeDataSource.getReplicationDelayMilliseconds();
             String status = StorageNodeStatus.valueOf(storageNodeDataSource.getStatus().toUpperCase()).name().toLowerCase();
-            return Arrays.asList(resource, status, null != replicationDelayTime ? Long.toString(replicationDelayTime) : "0");
+            return Arrays.asList(resource, status, Long.toString(replicationDelayMilliseconds));
         }
     }
 }