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 A3F0010D29 for ; Mon, 10 Feb 2014 02:43:38 +0000 (UTC) Received: (qmail 36956 invoked by uid 500); 10 Feb 2014 02:43:38 -0000 Delivered-To: apmail-curator-user-archive@curator.apache.org Received: (qmail 36923 invoked by uid 500); 10 Feb 2014 02:43:37 -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 36915 invoked by uid 99); 10 Feb 2014 02:43:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 02:43:37 +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 comptechgeeky@gmail.com designates 74.125.82.179 as permitted sender) Received: from [74.125.82.179] (HELO mail-we0-f179.google.com) (74.125.82.179) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 02:43:30 +0000 Received: by mail-we0-f179.google.com with SMTP id q58so3857846wes.10 for ; Sun, 09 Feb 2014 18:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=4BSyNL52cRNtvb9pxbg9eh7KhGMC3RRVda6aAYvesbU=; b=NCaf7KbtB4zXWpg3NjVrm7zAZjMKemIXfyfXUolc6JUzIiGBr0XwAjyiRaoqnrN3IF C5mJ24J6FNOC0oJ9PhwmV5dAMJW2DpmpAPv9DCw9D5AAgQTWZcQx9RiJLl4StxWLnBrp EavO4StMazdIQA6DwGFJFYRXpBua2TsTgsJtQhCExZyhRalCio31rzMmced4aVwn6sXT nEWDxiWC7n1/tc71YmWflIaeSvEj6BWUcWEO9EiRXXOV3ED0cocrJwCp1qaej7LJ06NT qv8M++sQac5AgwwOe/vPZj9S9DT3jPOlKNMPH9g/hPXouv6VhQ8Pcu1sxxnfMfqg4fyr rTcQ== X-Received: by 10.180.25.46 with SMTP id z14mr8412825wif.49.1392000190070; Sun, 09 Feb 2014 18:43:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.35.35 with HTTP; Sun, 9 Feb 2014 18:42:49 -0800 (PST) In-Reply-To: References: From: Check Peck Date: Sun, 9 Feb 2014 18:42:49 -0800 Message-ID: Subject: Re: How to watch on descendant znodes using Curator PathCache? To: Jordan Zimmerman Cc: user Content-Type: multipart/alternative; boundary=bcaec54b4994db455704f2044c7a X-Virus-Checked: Checked by ClamAV on apache.org --bcaec54b4994db455704f2044c7a Content-Type: text/plain; charset=ISO-8859-1 Sure Jordan. Let me take a look into that. In the meantime, is there any workaround for this for now which I can try it out or if you have any example which I can take a look? On Sun, Feb 9, 2014 at 6:41 PM, Jordan Zimmerman wrote: > Sorry - I thought you were using NodeCache. There's already an issue to > add recursive support to PathChildrenCache: > https://issues.apache.org/jira/browse/CURATOR-33 - I'm waiting for the > author of the patch to respond to some comments. Maybe you can take on this > issue as I haven't heard back from him.. > > -JZ > > ------------------------------ > From: Check Peck Check Peck > Reply: Check Peck comptechgeeky@gmail.com > Date: February 9, 2014 at 9:35:24 PM > To: Jordan Zimmerman jordan@jordanzimmerman.com > Subject: Re: How to watch on descendant znodes using Curator PathCache? > > Thanks for suggestion. I am using PathChildrenCache for one level. For > example - > > If my root node is - "/my/test" and I am keeping a watch on that node > using the PathChildrenCache as mentioned in my previous email code. So > suppose if these nodes gets added to my root node - > > "/my/test/test1" > "/my/test/test2" > "/my/test/test3" > > Then I get notified and it works fine with the PathChildrenCache code but > if any new node gets added, updated or removed to `"/my/test/test1"`, > `"/my/test/test2"` and `"/my/test/test3"` then it doesn't works and no > watches gets triggered and I am not able to understand how to make that > work as my understanding is very limited as of now. > > > > On Sun, Feb 9, 2014 at 6:31 PM, Jordan Zimmerman < > jordan@jordanzimmerman.com> wrote: > >> Do you need just the one level? If so, why not use PathChildrenCache: >> http://curator.apache.org/curator-recipes/path-cache.html >> >> -JZ >> >> ------------------------------ >> From: Check Peck Check Peck >> Reply: user@curator.apache.org user@curator.apache.org >> Date: February 9, 2014 at 9:08:20 PM >> To: user user@curator.apache.org >> Subject: How to watch on descendant znodes using Curator PathCache? >> >> I am working on a project in which I need to maintain a watches on a >> node, and that nodes children as well. I have tried using PathCache but I >> am not sure how to watch for childrens children here? >> >> Here my root node is - `"/my/test"` and I am keeping a watch on that node >> using the below code. What I want to do is, to keep the watch on >> `"/my/test"` znode. So suppose if these nodes gets added to my root node - >> >> "/my/test/test1" >> "/my/test/test2" >> "/my/test/test3" >> >> Then I should get notified (till this part I am able to make it work) but >> if any new node gets added, updated or removed to `"/my/test/test1"`, >> `"/my/test/test2"` and `"/my/test/test3"` then I should also get notified >> and this is the part I am not able to understand how to make it work. >> >> Whenever I am adding any new node to `"/my/test"` such as >> `"/my/test/test1"`, `"/my/test/test2"`, `"/my/test/test3"` then the watch >> gets triggered with the use of below code. But if I am adding any new node >> to `"/my/test/test1"` or `"/my/test/test2"`, then no watches get triggerd >> and I am not sure how to add the code for that as well? Any thoughts how >> this can be done? >> >> May be if somebody has done this in the past.. So any example will be of >> great help to me.. >> >> Below is my code which works fine for `"/my/test"` children but not the >> childrens of `"/my/test/test1"` and etc etc. >> >> private static final String PATH = "/my/test"; >> >> public static void main(String[] args) { >> CuratorFramework client = null; >> PathChildrenCache cache = null; >> try { >> client = CuratorClient.createSimple("localhost:2181"); >> client.start(); >> >> // in this example we will cache data. Notice that this is >> optional. >> cache = new PathChildrenCache(client, PATH, true); >> cache.start(); >> >> addListener(cache); >> >> for(;;) { >> try { >> Thread.sleep(50000); >> } catch(InterruptedException e) { >> } >> } >> } catch (Exception e1) { >> e1.printStackTrace(); >> } >> } >> >> Below is my addListener method - >> >> private static void addListener(PathChildrenCache cache) { >> >> PathChildrenCacheListener listener = new >> PathChildrenCacheListener() { >> public void childEvent(CuratorFramework client, >> PathChildrenCacheEvent event) throws Exception { >> switch (event.getType()) { >> case CHILD_ADDED: { >> System.out.println("Node added: " + >> ZKPaths.getNodeFromPath(event.getData().getPath())); >> break; >> } >> >> case CHILD_UPDATED: { >> System.out.println("Node changed: " + >> ZKPaths.getNodeFromPath(event.getData().getPath())); >> break; >> } >> >> case CHILD_REMOVED: { >> System.out.println("Node removed: " + >> ZKPaths.getNodeFromPath(event.getData().getPath())); >> break; >> } >> default: >> break; >> } >> } >> }; >> cache.getListenable().addListener(listener); >> } >> >> Can anyone provide a simple example for this for my use case? I am using >> Curator 2.4.0 which got released recently. >> >> > --bcaec54b4994db455704f2044c7a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Sure Jordan. Let me take a look into that. In the meantime= , is there any workaround for this for now which I can try it out or if you= have any example which I can take a look?


On Sun, Feb 9, 2014 at 6:41 PM, Jordan Z= immerman <jordan@jordanzimmerman.com> wrote:
Sorry = - I thought you were using NodeCache. There’s already an issue to add= recursive support to PathChildrenCache: https://issues.apache.org= /jira/browse/CURATOR-33 - I’m waiting for the author of the = patch to respond to some comments. Maybe you can take on this issue as I ha= ven’t heard back from him..

-JZ

From: <= span style=3D"color:black">Check Peck Check Peck
Reply: Check Peck comptechgeeky@gmail.com
Date: February 9, 2014 at 9:35:24 PM=
To: Jordan Zimmerman
jordan@jordanz= immerman.com
Subject:  Re: How to watch on descendant z= nodes using Curator PathCache?
Thanks for suggestion. I am using PathChildrenCache for one level. For example -

If my root node is - "/my/test" and I am keeping a watch on that node using the PathChildrenCache as mentioned in my previous email code. So suppose if these nodes gets added to my root node -

    "/my/test/test1"
    "/my/test/test2"
    "/my/test/test3"
   
Then I get notified and it works fine with the PathChildrenCache code but if any new node gets added, updated or removed to `"/my/test/test1"`, `"/my/test/test2"` and `"/my/t= est/test3"` then it doesn't works and no watches gets triggered and I am not able to understand how to make that work as my understanding is very limited as of now.



On Sun, Feb 9, 2014 at 6:31 PM, Jordan Zimmerman <jordan@jordanzimmerman.com> wrote:
Do you need just the one level? If so, why not use PathChildrenCache: http://curator.apache.org/curator-reci= pes/path-cache.html

-JZ


From: Check Peck Check Peck
Reply: user@curator.apache.org user@curator.apache.org<= br> Date: February 9, 2014 at 9:08:20 PM
To: user user@curator.apache.org
Subject:  How to watch on descendant znodes using Curator PathCache?
I am working on a project in which I need to maintain a watches on a node, and that nodes children as well. I have tried using PathCache but I am not sure how to watch for childrens children here?

Here my root node is - `"/my/test"` and I am keeping a watch on that node using the below code. What I want to do is, to keep the watch on `"/my/test"` znode. So suppose if these nodes gets added to my root node -

    "/my/test/test1"
    "/my/test/test2"
    "/my/test/test3"
   
Then I should get notified (till this part I am able to make it work) but if any new node gets added, updated or removed to `"/my/test/test1"`, `"/my/test/test2"` and `"/my/t= est/test3"` then I should also get notified and this is the part I am not able to understand how to make it work.

Whenever I am adding any new node to `"/my/test"` such as `"/my/test/test1"`, `"/my/test/test2"`, `"/my/test= /test3"` then the watch gets triggered with the use of below code. But if I am adding any new node to `"/my/test/test1"` or `"/my/test/test2"= `, then no watches get triggerd and I am not sure how to add the code for that as well? Any thoughts how this can be done?

May be if somebody has done this in the past.. So any example will be of great help to me..

Below is my code which works fine for `"/my/test"` children but n= ot the childrens of `"/my/test/test1"` and etc etc.
  
    private static final String PATH =3D "/my/test";

    public static void main(String[] args) {
        CuratorFramework client =3D null;
        PathChildrenCache cache =3D null;
        try {
            client =3D CuratorClient.createSimple("localhost:2181");
            client.start();

            // in this example we will cache data. Notice that this is optional.
            cache =3D new PathChildrenCache(client, PATH, true);
            cache.start();

            addListener(cache);

            for(;;) {
            &nb= sp;   try {
            &nb= sp;       Thread.sleep(50000);
            &nb= sp;   } catch(InterruptedException e) {
            &nb= sp;   }
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
  
Below is my addListener method -   

    private static void addListener(PathChildrenCache cache) {

        PathChildrenCacheListener listener =3D new PathChildrenCacheListener() {
            public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
            &nb= sp;   switch (event.getType()) {
            &nb= sp;   case CHILD_ADDED: {
            &nb= sp;       System.out.println("Node added: " + ZKPaths.getNodeFromPath(event.getData().getPath()));
            &nb= sp;       break;
            &nb= sp;   }

            &nb= sp;   case CHILD_UPDATED: {
            &nb= sp;       System.out.println("Node changed: "    + ZKPaths.getNodeFromPath(event.getData().getPath()));
            &nb= sp;       break;
            &nb= sp;   }

            &nb= sp;   case CHILD_REMOVED: {
            &nb= sp;       System.out.println("Node removed: "    + ZKPaths.getNodeFromPath(event.getData().getPath()));
            &nb= sp;       break;
            &nb= sp;   }
            &nb= sp;   default:
            &nb= sp;       break;
            &nb= sp;   }
            }
        };
        cache.getListenable().addListener(listener);
    }
   
Can anyone provide a simple example for this for my use case? I am using Curator 2.4.0 which got released recently.


--bcaec54b4994db455704f2044c7a--