zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] anmolnar commented on a change in pull request #730: Zookeeper-3188: Improve resilience to network
Date Wed, 27 Feb 2019 14:41:41 GMT
anmolnar commented on a change in pull request #730: Zookeeper-3188: Improve resilience to
network
URL: https://github.com/apache/zookeeper/pull/730#discussion_r260756137
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java
 ##########
 @@ -306,6 +279,82 @@ protected void connectToLeader(InetSocketAddress addr, String hostname)
         leaderOs = BinaryOutputArchive.getArchive(bufferedOutput);
     }
 
+    class LeaderConnector implements Runnable {
+
+        private AtomicReference<Socket> socket;
+        private InetSocketAddress address;
+        private CountDownLatch latch;
+
+        LeaderConnector(InetSocketAddress address, AtomicReference<Socket> socket,
CountDownLatch latch) {
+            this.address = address;
+            this.socket = socket;
+            this.latch = latch;
+        }
+
+        @Override
+        public void run() {
+            try {
+                Thread.currentThread().setName("LeaderConnector-" + address);
+                Socket sock = connectToLeader();
+
+                if(sock != null && sock.isConnected() && !socket.compareAndSet(null,
sock))
+                    sock.close();
 
 Review comment:
   Please consider adding a short log message to indicate that you close a redundant connection
to the leader.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message