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 B5DC3200BFE for ; Mon, 16 Jan 2017 21:23:35 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B48B3160B4D; Mon, 16 Jan 2017 20:23:35 +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 0FF0C160B28 for ; Mon, 16 Jan 2017 21:23:34 +0100 (CET) Received: (qmail 95194 invoked by uid 500); 16 Jan 2017 20:23:34 -0000 Mailing-List: contact dev-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 dev@curator.apache.org Received: (qmail 95182 invoked by uid 99); 16 Jan 2017 20:23:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2017 20:23:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A2035C10E7 for ; Mon, 16 Jan 2017 20:23:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id KaN5Pzh_q31N for ; Mon, 16 Jan 2017 20:23:30 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 6E5075FE2D for ; Mon, 16 Jan 2017 20:23:30 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1EEC6E0479 for ; Mon, 16 Jan 2017 20:23:29 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id C74D52529A for ; Mon, 16 Jan 2017 20:23:26 +0000 (UTC) Date: Mon, 16 Jan 2017 20:23:26 +0000 (UTC) From: "Scott Blum (JIRA)" To: dev@curator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CURATOR-171) LeaderLatch isn't aware if it's own ephemeral node goes away MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 16 Jan 2017 20:23:35 -0000 [ https://issues.apache.org/jira/browse/CURATOR-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15824551#comment-15824551 ] Scott Blum commented on CURATOR-171: ------------------------------------ I could totally get on board with the idea that everyone watches exactly one node, and the leader watches himself. It's one extra watch, not per node, but per election. Seems a small price to pay if it allows you to externally nuke the election and retry to fix a borked state. > LeaderLatch isn't aware if it's own ephemeral node goes away > ------------------------------------------------------------ > > Key: CURATOR-171 > URL: https://issues.apache.org/jira/browse/CURATOR-171 > Project: Apache Curator > Issue Type: Bug > Components: Recipes > Reporter: John Vines > > Running the following code- {code} public static void main(String args[]) throws Exception { > CuratorFramework curator = CuratorFrameworkFactory.builder().connectString("localhost:2181").retryPolicy(new ExponentialBackoffRetry(1000, 5)) > .authorization("digest", "accumulo:DEFAULT".getBytes()).build(); > curator.start(); > LeaderLatch latch = new LeaderLatch(curator, "/latch", "test"); > LeaderLatch latch2 = new LeaderLatch(curator, "/latch", "test2"); > latch.addListener(new LeaderLatchListener() { > @Override > public void isLeader() { > System.out.println("Became leader!"); > } > @Override > public void notLeader() { > System.out.println("Lost leadership!"); > } > }); > latch.start(); > latch.await(); > latch2.start(); > Thread.sleep(1000); > System.out.println("Does latch1 have leadership? " + latch.hasLeadership()); > System.out.println("Does latch2 have leadership? " + latch2.hasLeadership()); > for (String child : curator.getChildren().forPath("/latch")) > if (Arrays.equals(curator.getData().forPath(ZKPaths.makePath("/latch", child)), "test".getBytes())) > curator.delete().deletingChildrenIfNeeded().forPath(ZKPaths.makePath("/latch", child)); > Thread.sleep(1000); > System.out.println("Does latch1 have leadership? " + latch.hasLeadership()); > System.out.println("Does latch2 have leadership? " + latch2.hasLeadership()); > > Thread.sleep(1000 * 40); > System.out.println("Does latch1 have leadership? " + latch.hasLeadership()); > System.out.println("Does latch2 have leadership? " + latch2.hasLeadership()); > > latch.close(); > latch2.close(); > curator.close(); > }{code} > I get the following output-{noformat}Became leader! > Does latch1 have leadership? true > Does latch2 have leadership? false > Does latch1 have leadership? true > Does latch2 have leadership? true > Does latch1 have leadership? true > Does latch2 have leadership? true > {noformat} > I expect that when the ephemeral node is deleted, latch1 no longer reports itself as having leadership. Furthermore, I expect it to trigger the notLeader call. -- This message was sent by Atlassian JIRA (v6.3.4#6332)