Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E6011200B2B for ; Tue, 14 Jun 2016 05:52:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E4F9A160A5E; Tue, 14 Jun 2016 03:52:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 40A28160A3C for ; Tue, 14 Jun 2016 05:52:33 +0200 (CEST) Received: (qmail 79517 invoked by uid 500); 14 Jun 2016 03:52:31 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 79505 invoked by uid 99); 14 Jun 2016 03:52:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2016 03:52:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 988E9DFB74; Tue, 14 Jun 2016 03:52:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cammckenzie@apache.org To: commits@curator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: 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 Date: Tue, 14 Jun 2016 03:52:31 +0000 (UTC) archived-at: Tue, 14 Jun 2016 03:52:34 -0000 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 Authored: Tue Jun 14 13:49:07 2016 +1000 Committer: Cam McKenzie 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