You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2018/12/20 09:23:49 UTC

asterixdb git commit: [NO ISSUE][OTH] Refactor Healthy ISocketChannel Check

Repository: asterixdb
Updated Branches:
  refs/heads/master 0ee48d0bd -> 1226c41fc


[NO ISSUE][OTH] Refactor Healthy ISocketChannel Check

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Refactor common logic to check for healthy ISocketChannel.
- Fix SslReplicationExecutionTest test name.

Change-Id: I340d369b40d6f4200a4fc6c6f1c7c377e10fccb0
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3096
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mh...@apache.org>
Reviewed-by: Till Westmann <ti...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/1226c41f
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/1226c41f
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/1226c41f

Branch: refs/heads/master
Commit: 1226c41fcc56805b180ecf8643bdb43bf6e32f38
Parents: 0ee48d0
Author: Murtadha Hubail <mh...@apache.org>
Authored: Wed Dec 19 20:29:35 2018 +0300
Committer: Murtadha Hubail <mh...@apache.org>
Committed: Thu Dec 20 01:23:07 2018 -0800

----------------------------------------------------------------------
 .../apache/asterix/test/runtime/SslReplicationExecutionTest.java | 2 +-
 .../org/apache/asterix/replication/api/PartitionReplica.java     | 3 ++-
 .../apache/asterix/replication/api/ReplicationDestination.java   | 4 ++--
 .../apache/asterix/replication/management/NetworkingUtil.java    | 4 ++++
 4 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1226c41f/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java
index 14aac1f..d4c9eb5 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java
@@ -78,7 +78,7 @@ public class SslReplicationExecutionTest {
         LangExecutionUtil.tearDown();
     }
 
-    @Parameters(name = "ReplicationExecutionTest {index}: {0}")
+    @Parameters(name = "SslReplicationExecutionTest {index}: {0}")
     public static Collection<Object[]> tests() throws Exception {
         return LangExecutionUtil.tests("replication.xml", "replication.xml");
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1226c41f/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
index 0e85665..ea48b8c 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java
@@ -29,6 +29,7 @@ import org.apache.asterix.common.api.INcApplicationContext;
 import org.apache.asterix.common.exceptions.ReplicationException;
 import org.apache.asterix.common.replication.IPartitionReplica;
 import org.apache.asterix.common.storage.ReplicaIdentifier;
+import org.apache.asterix.replication.management.NetworkingUtil;
 import org.apache.asterix.replication.messaging.ReplicationProtocol;
 import org.apache.asterix.replication.sync.ReplicaSynchronizer;
 import org.apache.hyracks.api.network.ISocketChannel;
@@ -95,7 +96,7 @@ public class PartitionReplica implements IPartitionReplica {
 
     public synchronized ISocketChannel getChannel() {
         try {
-            if (sc == null || !sc.getSocketChannel().isOpen() || !sc.getSocketChannel().isConnected()) {
+            if (!NetworkingUtil.isHealthy(sc)) {
                 sc = ReplicationProtocol.establishReplicaConnection(appCtx, id.getLocation());
             }
             return sc;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1226c41f/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java
index eda37b5..ef1bc28 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java
@@ -29,6 +29,7 @@ import org.apache.asterix.common.api.INcApplicationContext;
 import org.apache.asterix.common.exceptions.ReplicationException;
 import org.apache.asterix.common.replication.IPartitionReplica;
 import org.apache.asterix.common.replication.IReplicationDestination;
+import org.apache.asterix.replication.management.NetworkingUtil;
 import org.apache.asterix.replication.messaging.ReplicationProtocol;
 import org.apache.hyracks.api.network.ISocketChannel;
 import org.apache.logging.log4j.LogManager;
@@ -77,8 +78,7 @@ public class ReplicationDestination implements IReplicationDestination {
 
     public synchronized ISocketChannel getLogReplicationChannel(INcApplicationContext appCtx) {
         try {
-            if (logRepChannel == null || !logRepChannel.getSocketChannel().isOpen()
-                    || !logRepChannel.getSocketChannel().isConnected()) {
+            if (!NetworkingUtil.isHealthy(logRepChannel)) {
                 logRepChannel = ReplicationProtocol.establishReplicaConnection(appCtx, location);
             }
             return logRepChannel;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1226c41f/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java
index 30ad72c..d572ba2 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java
@@ -127,4 +127,8 @@ public class NetworkingUtil {
     public static SocketAddress getSocketAddress(NetworkAddress netAddr) throws UnknownHostException {
         return new InetSocketAddress(InetAddress.getByAddress(netAddr.lookupIpAddress()), netAddr.getPort());
     }
+
+    public static boolean isHealthy(ISocketChannel sc) {
+        return sc != null && sc.getSocketChannel().isOpen() && sc.getSocketChannel().isConnected();
+    }
 }