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 87997200B49 for ; Wed, 3 Aug 2016 22:27:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 86319160A86; Wed, 3 Aug 2016 20:27:49 +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 A9065160A5D for ; Wed, 3 Aug 2016 22:27:48 +0200 (CEST) Received: (qmail 52408 invoked by uid 500); 3 Aug 2016 20:27:47 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 52399 invoked by uid 99); 3 Aug 2016 20:27:47 -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; Wed, 03 Aug 2016 20:27:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AAEFBE3839; Wed, 3 Aug 2016 20:27:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jlowe@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HADOOP-10980. TestActiveStandbyElector fails occasionally in trunk. Contributed by Eric Badger (cherry picked from commit c82745432a962c817a8a7db92bb830fb6af01e33) Date: Wed, 3 Aug 2016 20:27:47 +0000 (UTC) archived-at: Wed, 03 Aug 2016 20:27:49 -0000 Repository: hadoop Updated Branches: refs/heads/branch-2.7 47e1eabf7 -> 2bf4e7637 HADOOP-10980. TestActiveStandbyElector fails occasionally in trunk. Contributed by Eric Badger (cherry picked from commit c82745432a962c817a8a7db92bb830fb6af01e33) Conflicts: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2bf4e763 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2bf4e763 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2bf4e763 Branch: refs/heads/branch-2.7 Commit: 2bf4e763706fc01239cc755a521ebf8ed0cb508a Parents: 47e1eab Author: Jason Lowe Authored: Wed Aug 3 20:27:15 2016 +0000 Committer: Jason Lowe Committed: Wed Aug 3 20:27:15 2016 +0000 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/ha/ActiveStandbyElector.java | 19 +++++++++++++++---- .../hadoop/ha/TestActiveStandbyElector.java | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bf4e763/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 0f836d5..d83146d 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -28,6 +28,9 @@ Release 2.7.4 - UNRELEASED HADOOP-11149. Increase the timeout of TestZKFailoverController. (Steve Loughran via wheat9) + HADOOP-10980. TestActiveStandbyElector fails occasionally in trunk + (Eric Badger via jlowe) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bf4e763/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java index 5264278..5eccbf2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java @@ -613,13 +613,13 @@ public class ActiveStandbyElector implements StatCallback, StringCallback { /** * Get a new zookeeper client instance. protected so that test class can - * inherit and pass in a mock object for zookeeper + * inherit and mock out the zookeeper instance * * @return new zookeeper client instance * @throws IOException * @throws KeeperException zookeeper connectionloss exception */ - protected synchronized ZooKeeper getNewZooKeeper() throws IOException, + protected synchronized ZooKeeper connectToZooKeeper() throws IOException, KeeperException { // Unfortunately, the ZooKeeper constructor connects to ZooKeeper and @@ -628,7 +628,7 @@ public class ActiveStandbyElector implements StatCallback, StringCallback { // we construct the watcher first, and have it block any events it receives // before we can set its ZooKeeper reference. watcher = new WatcherWithClientRef(); - ZooKeeper zk = new ZooKeeper(zkHostPort, zkSessionTimeout, watcher); + ZooKeeper zk = createZooKeeper(); watcher.setZooKeeperRef(zk); // Wait for the asynchronous success/failure. This may throw an exception @@ -641,6 +641,17 @@ public class ActiveStandbyElector implements StatCallback, StringCallback { return zk; } + /** + * Get a new zookeeper client instance. protected so that test class can + * inherit and pass in a mock object for zookeeper + * + * @return new zookeeper client instance + * @throws IOException + */ + protected ZooKeeper createZooKeeper() throws IOException { + return new ZooKeeper(zkHostPort, zkSessionTimeout, watcher); + } + private void fatalError(String errorMessage) { LOG.fatal(errorMessage); reset(); @@ -772,7 +783,7 @@ public class ActiveStandbyElector implements StatCallback, StringCallback { zkClient = null; watcher = null; } - zkClient = getNewZooKeeper(); + zkClient = connectToZooKeeper(); LOG.debug("Created new connection for " + this); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bf4e763/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestActiveStandbyElector.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestActiveStandbyElector.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestActiveStandbyElector.java index 83a3a4f..8c6f7a3 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestActiveStandbyElector.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestActiveStandbyElector.java @@ -66,7 +66,7 @@ public class TestActiveStandbyElector { } @Override - public ZooKeeper getNewZooKeeper() { + public ZooKeeper connectToZooKeeper() { ++count; return mockZK; } @@ -749,7 +749,15 @@ public class TestActiveStandbyElector { try { new ActiveStandbyElector("127.0.0.1", 2000, ZK_PARENT_NAME, Ids.OPEN_ACL_UNSAFE, Collections. emptyList(), mockApp, - CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT); + CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT) { + + @Override + protected ZooKeeper createZooKeeper() throws IOException { + return Mockito.mock(ZooKeeper.class); + } + }; + + Assert.fail("Did not throw zookeeper connection loss exceptions!"); } catch (KeeperException ke) { GenericTestUtils.assertExceptionContains( "ConnectionLoss", ke); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org