zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject zookeeper git commit: ZOOKEEPER-1748: Add option for tcp keepalive
Date Thu, 08 Jun 2017 15:42:22 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.4 3289ebbaa -> 51cdeb407


ZOOKEEPER-1748: Add option for tcp keepalive

As referenced in https://issues.apache.org/jira/browse/ZOOKEEPER-1748 and https://github.com/apache/zookeeper/pull/83,
add the option to use keepalived on quorum connections.  These connections are often idle
and long-lived, thus tend to be silently dropped by intermediate networking infrastructure
(AWS Security Groups' state tables, for example).

This PR adds the option to use the system's keepalive functionality when creating the socket
for quorum connections.

It does not change existing behavior.

Author: Ben <bensherman@gmail.com>
Author: Ben Sherman <bsherman@axon.com>

Reviewers: Michael Han <hanm@apache.org>, Abe Fine <afine@apache.org>

Closes #274 from bensherman/ZOOKEEPER-1748


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/51cdeb40
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/51cdeb40
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/51cdeb40

Branch: refs/heads/branch-3.4
Commit: 51cdeb407cfb7887e647ba7d34718232e6108409
Parents: 3289ebb
Author: Ben <bensherman@gmail.com>
Authored: Thu Jun 8 08:42:19 2017 -0700
Committer: Michael Han <hanm@apache.org>
Committed: Thu Jun 8 08:42:19 2017 -0700

----------------------------------------------------------------------
 docs/zookeeperAdmin.html                           | 17 ++++++++++++++++-
 .../zookeeper/server/quorum/QuorumCnxManager.java  |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/51cdeb40/docs/zookeeperAdmin.html
----------------------------------------------------------------------
diff --git a/docs/zookeeperAdmin.html b/docs/zookeeperAdmin.html
index 140c997..f074a35 100644
--- a/docs/zookeeperAdmin.html
+++ b/docs/zookeeperAdmin.html
@@ -1446,7 +1446,22 @@ server.3=zoo3:2888:3888</pre>
               </pre>
 </dd>
 
-        
+<dt>
+<term>tcpKeepAlive</term>
+</dt>
+<dd>
+<p>(Java system property: <strong>zookeeper.tcpKeepAlive</strong>)</p>
+<p>
+<strong>New in 3.4.11:</strong>
+              Sets the keepAlive flag on the sockets used by quorum members to perform elections.
+              This will allow for connections between quorum members to remain up when there
is 
+              network infrastructure that may otherwise terminate them. Some NATs and firewalls
may
+              terminate or lose state for long running or idle connections. </p>
+              Enabling this option relies on OS level settings to work properly, check your
operating
+              system's options regarding TCP keepalive for more information.
+              Defaults to <strong>false</strong>.</p>
+</dd>
+
 </dl>
 <p></p>
 <a name="sc_authOptions"></a>

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/51cdeb40/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
index 878008b..ec6be4a 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
@@ -107,6 +107,7 @@ public class QuorumCnxManager {
     final long mySid;
     final int socketTimeout;
     final Map<Long, QuorumPeer.QuorumServer> view;
+    final boolean tcpKeepAlive = Boolean.getBoolean("zookeeper.tcpKeepAlive");
     final boolean listenOnAllIPs;
     private ThreadPoolExecutor connectionExecutor;
     private final Set<Long> inprogressConnections = Collections
@@ -661,6 +662,7 @@ public class QuorumCnxManager {
      */
     private void setSockOpts(Socket sock) throws SocketException {
         sock.setTcpNoDelay(true);
+        sock.setKeepAlive(tcpKeepAlive);
         sock.setSoTimeout(socketTimeout);
     }
 


Mime
View raw message