Return-Path: X-Original-To: apmail-curator-user-archive@minotaur.apache.org Delivered-To: apmail-curator-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E1EC109C5 for ; Fri, 8 Nov 2013 20:32:14 +0000 (UTC) Received: (qmail 14084 invoked by uid 500); 8 Nov 2013 20:32:14 -0000 Delivered-To: apmail-curator-user-archive@curator.apache.org Received: (qmail 14053 invoked by uid 500); 8 Nov 2013 20:32:14 -0000 Mailing-List: contact user-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@curator.apache.org Delivered-To: mailing list user@curator.apache.org Received: (qmail 14040 invoked by uid 99); 8 Nov 2013 20:32:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Nov 2013 20:32:13 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mckenzie.cam@gmail.com designates 209.85.220.43 as permitted sender) Received: from [209.85.220.43] (HELO mail-pa0-f43.google.com) (209.85.220.43) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Nov 2013 20:32:07 +0000 Received: by mail-pa0-f43.google.com with SMTP id hz1so2701936pad.2 for ; Fri, 08 Nov 2013 12:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=c1kwb6v80rc/mSAKAzHiAU5QgqP2tP/RvdLJED1iL7g=; b=rOu6IgEI6SsBK6VO3Ekmg0q9taO/J8BWEkjNr0CTSy+NtwjiQhNR+CYQruPUWKG1du pGolpTy6R03pMeYB+8l2dDZzLzMuYT0t0Ni53/f1xx6jlRSkJvVwgg5nJDBDRhOwivPj YJKjJ7B4kT4QGGLo4s0sclL1C+F4KYEHpz8WKxvCDd51va8ipnYOSPOPnQBKwrlfMmOe Y3sZGmfwyiIKpUVHXJhKXxRqS12wrBDfJI/RivcPUy4Xoia2aySHOkORplHTS0/1kijw KIpQ+ABOYbTxtZ+rJV2UqriT8L4wE36WWBmKUgPvdHVOrf9qWm715zKGKDDeQB70jhlK dTLA== MIME-Version: 1.0 X-Received: by 10.68.166.67 with SMTP id ze3mr16810064pbb.173.1383942706036; Fri, 08 Nov 2013 12:31:46 -0800 (PST) Received: by 10.68.236.7 with HTTP; Fri, 8 Nov 2013 12:31:45 -0800 (PST) In-Reply-To: References: Date: Sat, 9 Nov 2013 07:31:45 +1100 Message-ID: Subject: Re: How to use Curator for Watching the nodes and trigger purpose From: Cameron McKenzie To: user@curator.apache.org Content-Type: multipart/alternative; boundary=047d7bacbde0620a0d04eab0450c X-Virus-Checked: Checked by ClamAV on apache.org --047d7bacbde0620a0d04eab0450c Content-Type: text/plain; charset=ISO-8859-1 client.getCuratorListenable().addListener(new CuratorListener() { public void eventReceived(CuratorFramework curator, CuratorEvent event) { //Your event handling code here. } }); client.getChildren().watched().forPath("/bla"); Note the 'watched()' call. This will return you all children currently under the path, and you will receive a watch event whenever children are added or removed from the parent node. Remember that you need to rewatch the parent node after each event. On Sat, Nov 9, 2013 at 7:17 AM, Techy Teck wrote: > I recently started working with Zookeeper and I am using Curator library > for this. I am able to create all kind of nodes and delete nodes as well. > > Now I started working on Watches but I am not able to get any simple > example how to use Curator library to do watches on any parent nodes and if > any new child nodes get added to these parent nodes, watches should get > triggered and perform some activity then. > > Is there any simple example that I can see on how watches works using > Curator library? Any github link will also be great. Thanks. > --047d7bacbde0620a0d04eab0450c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
client.getCuratorListenable().addListener(new Curator= Listener() {
=A0 =A0 public void eventReceived(CuratorFramework c= urator, CuratorEvent event) {
=A0 =A0 =A0 =A0 //Your event handli= ng code here.
=A0 =A0 }
});

client.getChildren().watch= ed().forPath("/bla");

Note the 'watched()&= #39; call.

This will return you all children curre= ntly under the path, and you will receive a watch event whenever children a= re added or removed from the parent node. Remember that you need to rewatch= the parent node after each event.




On Sat, Nov 9, 2013 at 7:17 AM, Techy Teck <c= omptechgeeky@gmail.com> wrote:
I recently starte= d working with Zookeeper and I am using Curator library for this. I am able= to create all kind of nodes and delete nodes as well.

Now I started working on Watches but I am not able to get any sim= ple example how to use Curator library to do watches on any parent nodes an= d if any new child nodes get added to these parent nodes, watches should ge= t triggered and perform some activity then.

Is there any simple example that I can see on how watches works u= sing Curator library? Any github link will also be great. Thanks.

--047d7bacbde0620a0d04eab0450c--