Murtadha Hubail has submitted this change and it was merged. Change subject: [NO ISSUE][OTH] Refactor Healthy ISocketChannel Check ......................................................................
[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 <[email protected]> Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Reviewed-by: Till Westmann <[email protected]> --- M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/SslReplicationExecutionTest.java M asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/PartitionReplica.java M asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/api/ReplicationDestination.java M asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/NetworkingUtil.java 4 files changed, 9 insertions(+), 4 deletions(-) Approvals: Anon. E. Moose #1000171: Till Westmann: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified Murtadha Hubail: Looks good to me, but someone else must approve 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 @@ 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"); } 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.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 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; 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.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 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; 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 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(); + } } -- To view, visit https://asterix-gerrit.ics.uci.edu/3096 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I340d369b40d6f4200a4fc6c6f1c7c377e10fccb0 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]>
