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 AE3CB17642 for ; Wed, 22 Apr 2015 08:33:40 +0000 (UTC) Received: (qmail 53517 invoked by uid 500); 22 Apr 2015 08:33:40 -0000 Delivered-To: apmail-curator-user-archive@curator.apache.org Received: (qmail 53486 invoked by uid 500); 22 Apr 2015 08:33:40 -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 53476 invoked by uid 99); 22 Apr 2015 08:33:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2015 08:33:40 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: message received from 54.76.25.247 which is an MX secondary for user@curator.apache.org) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2015 08:33:12 +0000 Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 3CCF125F85 for ; Wed, 22 Apr 2015 08:33:09 +0000 (UTC) Received: by qkgx75 with SMTP id x75so216676598qkg.1 for ; Wed, 22 Apr 2015 01:33:08 -0700 (PDT) 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=tLnAZP2B1gtGUoq3ovwCjseAKwgtdptcvnUP+eZIfzE=; b=KRREWVb6yatkc0jpWTOifxKbm/qHpgqHtO1ljeV3amRtsh4fvpvWlMowsMETbl8yph uFyFopzTAVXJ6JRPCT0v0VRli4k6Ui31nlqofgsgexLSaFIVo2oKZzqLyKI3MsfSlsEG HYN8syUeCJpe3Nb7EC6utesSJephfx1Iu+yxoH8i/KvtsFlbKxzsn+heA2RnKCEZ3XD8 El/w4mAAPYocLSaQLDbgZ4xbrLAJUI+dkkrVRKkO+fAmYNkQmHvCOLCNh0+Y3ayl2EQ5 /Ph8fHowmCKpThUydB97+snQrZu+zfQRvPPDItJINeOaWrMeM8/EKgK9lYvOodjQQ65D ip6A== MIME-Version: 1.0 X-Received: by 10.55.20.159 with SMTP id 31mr45976546qku.64.1429691588133; Wed, 22 Apr 2015 01:33:08 -0700 (PDT) Received: by 10.140.107.52 with HTTP; Wed, 22 Apr 2015 01:33:08 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Apr 2015 10:33:08 +0200 Message-ID: Subject: Re: Not receiving remove events on PathChildrenCache From: Arbi Akhina To: user Content-Type: multipart/alternative; boundary=001a113b0bfe3fc9ca05144c0334 X-Virus-Checked: Checked by ClamAV on apache.org --001a113b0bfe3fc9ca05144c0334 Content-Type: text/plain; charset=UTF-8 @Jordan I'll try with the ServiceCacheListener (didn't see it before :( @Scott yeah the node is removed from ZK but no event is triggered, I didn't try with TreeCache On Tue, Apr 21, 2015 at 8:18 PM, Scott Blum wrote: > Hi Arbi, > > Is the node actually removed in ZK that you're expecting the event for? > Also, if you try it with TreeCache, do you get the removal event? > > On Tue, Apr 21, 2015 at 2:15 PM, Arbi Akhina > wrote: > >> I'm using Apache Curator for service discovery, and PathChildrenCache to >> listen for events when a service is added/updated/deleted. >> >> PathChildrenCache pathCache = new PathChildrenCache(client, "/directory", true); >> pathCache.getListenable().addListener(new PathChildrenCacheListener() { >> @Override >> public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { >> if(event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED) { >> System.out.println("Added"); >> }else if(event.getType() == PathChildrenCacheEvent.Type.CHILD_UPDATED) { >> System.out.println("Updated"); >> }else if(event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED) { >> System.out.println("Removed"); >> } >> }} >> pathCache.start(); >> >> When I register a service through >> org.apache.curator.x.discovery.ServiceDiscovery, I got an added event. >> But when I un-register a service I don't get the removed event. >> >> How I could properly listen to service events? >> >> > --001a113b0bfe3fc9ca05144c0334 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
@Jordan I'll try with the ServiceCacheListener (didn&#= 39;t see it before :(
@Scott yeah the node is removed from ZK but no ev= ent is triggered, I didn't try with TreeCache

On Tue, Apr 21, 2015 at 8:18 PM= , Scott Blum <dragonsinth@gmail.com> wrote:
Hi Arbi,

Is the n= ode actually removed in ZK that you're expecting the event for?
Also, if you try it with TreeCache, do you get the removal event?
<= /div>
On Tue, Apr 21, 2015 at 2:15 PM, Arbi Akhina <arbi.akhina@gmail.com> wrote:

I'm using Apache Curator for service discovery, and=C2=A0PathChildrenCache=C2=A0to listen for events when a service is= added/updated/deleted.

PathChildrenCache pat=
hCache =3D new PathChildrenCache(client, "/directory", true<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);=

pathCache.getListenable().addListener(new PathChildrenCacheListener()<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> <=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  @Override
  public void childEvent(CuratorFramework client, PathChildrenCacheEven=
t=
 event) throws Exception {
    if(event.getType() =3D=3D PathChildrenCacheEvent.Type.CHILD_ADDED<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> <=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{<=
span style=3D"margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
      System.out.println("Added");
    }else if(event.getType() =3D=3D PathChildrenCacheEvent.Type.CHILD_UPDATED<=
/span>)<=
/span> <=
/span>{<=
/span>
      System.out.println("Updated");
    }else if(event.getType() =3D=3D PathChildrenCacheEvent.Type.CHILD_REMOVED<=
/span>)<=
/span> <=
/span>{<=
/span>
      System.out.println("Removed");
    }
  }
}=

pathCache.start();

When I register a service = through=C2=A0org.apache.curator.x.discovery.ServiceDiscovery<= /code>, I got an added event. But when I un-register a service I don't = get the removed event.

How I could properly listen to serv= ice events?




--001a113b0bfe3fc9ca05144c0334--