You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/06/14 03:52:31 UTC

curator git commit: #noissue - Modified connection state handling so that the poll period when in a SUSPENDED state will match the remaining amount of time left until the session expires, rather than 2/3 of the session timeout. This will cause the LOST

Repository: curator
Updated Branches:
  refs/heads/long_session_timeout_issue 1e07c779a -> ef3627558


 #noissue - Modified connection state handling so that the poll period when in a SUSPENDED state will match the remaining amount of time left until the session expires, rather than 2/3 of the session timeout. This will cause the LOST event to get triggered at the end of the session timeout window. Updated a few unit tests that were failing intermitently due to timing issues.


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

Branch: refs/heads/long_session_timeout_issue
Commit: ef36275585fb883bb54db5a1396c58bb42b9b25b
Parents: 1e07c77
Author: Cam McKenzie <ca...@apache.org>
Authored: Tue Jun 14 13:49:07 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Tue Jun 14 13:49:07 2016 +1000

----------------------------------------------------------------------
 .../apache/curator/framework/state/ConnectionStateManager.java  | 4 +++-
 .../apache/curator/framework/imps/TestFailedDeleteManager.java  | 2 +-
 .../framework/recipes/locks/TestInterProcessSemaphore.java      | 5 ++---
 3 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/ef362755/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
index cbb8d16..c420a12 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
@@ -252,7 +252,9 @@ public class ConnectionStateManager implements Closeable
             {
                 int lastNegotiatedSessionTimeoutMs = client.getZookeeperClient().getLastNegotiatedSessionTimeoutMs();
                 int useSessionTimeoutMs = (lastNegotiatedSessionTimeoutMs > 0) ? lastNegotiatedSessionTimeoutMs : sessionTimeoutMs;
-                int pollMaxMs = (useSessionTimeoutMs * 2) / 3; // 2/3 of session timeout
+                long elapsedMs = startOfSuspendedEpoch == 0 ? 0 : System.currentTimeMillis() - startOfSuspendedEpoch;
+                long pollMaxMs = useSessionTimeoutMs - elapsedMs;
+
                 final ConnectionState newState = eventQueue.poll(pollMaxMs, TimeUnit.MILLISECONDS);
                 if ( newState != null )
                 {

http://git-wip-us.apache.org/repos/asf/curator/blob/ef362755/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
index 943529f..41b0bca 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFailedDeleteManager.java
@@ -140,7 +140,7 @@ public class TestFailedDeleteManager extends BaseClassForTests
                 client.delete().guaranteed().forPath("/test-me");
                 Assert.fail();
             }
-            catch ( KeeperException.ConnectionLossException e )
+            catch ( KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e )
             {
                 // expected
             }

http://git-wip-us.apache.org/repos/asf/curator/blob/ef362755/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
index 7e821d0..079b12c 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
@@ -148,10 +148,9 @@ public class TestInterProcessSemaphore extends BaseClassForTests
                     }
                 }
             });
-
-            timing.sleepABit();
+      
             server.stop();
-            Assert.assertTrue(timing.awaitLatch(lostLatch));
+            Assert.assertTrue(timing.multiple(2).awaitLatch(lostLatch));
             InterProcessSemaphoreV2.debugAcquireLatch.countDown();  // the waiting semaphore proceeds to getChildren - which should fail
             Assert.assertTrue(timing.awaitLatch(InterProcessSemaphoreV2.debugFailedGetChildrenLatch));  // wait until getChildren fails