curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [14/14] curator git commit: Use the negotiated session timeout in checkTimeouts()
Date Tue, 01 Sep 2015 02:48:31 GMT
Use the negotiated session timeout in checkTimeouts()


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/667b1d2c
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/667b1d2c
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/667b1d2c

Branch: refs/heads/CURATOR-247
Commit: 667b1d2c7bd4b267585ae973dfff0f8b49f6b6ba
Parents: 72f7223
Author: randgalt <randgalt@apache.org>
Authored: Mon Aug 31 19:48:12 2015 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Mon Aug 31 19:48:12 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/curator/ConnectionState.java      | 6 ++++--
 .../apache/curator/connection/ConnectionHandlingPolicy.java    | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/667b1d2c/curator-client/src/main/java/org/apache/curator/ConnectionState.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ConnectionState.java b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
index f0996d8..eea2ce0 100644
--- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java
+++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
@@ -207,7 +207,9 @@ class ConnectionState implements Watcher, Closeable
                 return zooKeeper.hasNewConnectionString();
             }
         };
-        ConnectionHandlingPolicy.CheckTimeoutsResult result = connectionHandlingPolicy.checkTimeouts(hasNewConnectionString,
connectionStartMs, sessionTimeoutMs, connectionTimeoutMs);
+        int lastNegotiatedSessionTimeoutMs = getLastNegotiatedSessionTimeoutMs();
+        int useSessionTimeoutMs = (lastNegotiatedSessionTimeoutMs > 0) ? lastNegotiatedSessionTimeoutMs
: sessionTimeoutMs;
+        ConnectionHandlingPolicy.CheckTimeoutsResult result = connectionHandlingPolicy.checkTimeouts(hasNewConnectionString,
connectionStartMs, useSessionTimeoutMs, connectionTimeoutMs);
         switch ( result )
         {
             default:
@@ -227,7 +229,7 @@ class ConnectionState implements Watcher, Closeable
                 if ( !Boolean.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES)
)
                 {
                     long elapsed = System.currentTimeMillis() - connectionStartMs;
-                    int maxTimeout = Math.max(sessionTimeoutMs, connectionTimeoutMs);
+                    int maxTimeout = Math.max(useSessionTimeoutMs, connectionTimeoutMs);
                     log.warn(String.format("Connection attempt unsuccessful after %d (greater
than max timeout of %d). Resetting connection and trying again with a new connection.", elapsed,
maxTimeout));
                 }
                 reset();

http://git-wip-us.apache.org/repos/asf/curator/blob/667b1d2c/curator-client/src/main/java/org/apache/curator/connection/ConnectionHandlingPolicy.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/connection/ConnectionHandlingPolicy.java
b/curator-client/src/main/java/org/apache/curator/connection/ConnectionHandlingPolicy.java
index 6cea67d..9b6b895 100644
--- a/curator-client/src/main/java/org/apache/curator/connection/ConnectionHandlingPolicy.java
+++ b/curator-client/src/main/java/org/apache/curator/connection/ConnectionHandlingPolicy.java
@@ -63,7 +63,7 @@ public interface ConnectionHandlingPolicy
      * @param hasNewConnectionString proc to call to check if there is a new connection string.
Important: the internal state is cleared after
      *                               this is called so you MUST handle the new connection
string if <tt>true</tt> is returned
      * @param connectionStartMs the epoch/ms time that the connection was first initiated
-     * @param sessionTimeoutMs the configured session timeout in milliseconds
+     * @param sessionTimeoutMs the configured/negotiated session timeout in milliseconds
      * @param connectionTimeoutMs the configured connection timeout in milliseconds
      * @return result
      * @throws Exception errors


Mime
View raw message