You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by xytd <ya...@teradata.com> on 2014/06/09 19:20:10 UTC
How to set a watch for a deletion of a node?
Is there way to watch for a deletion of a child node? The callback thus
contains the node path which is being deleted.
The only way I would see it to work is to load a list of the children and
when a ChildrenWatch gets triggered, use it to compare with the list of
children returned. But this is not very intuitive. There must be a better
way to do this?
Thanks for any suggestion,
Yang
--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/How-to-set-a-watch-for-a-deletion-of-a-node-tp7579974.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Re: How to set a watch for a deletion of a node?
Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
Have a look at Curator. It has a recipe to do this exact thing: PathChildrenCache
https://curator.apache.org/curator-recipes/path-cache.html
-Jordan
From: xytd yang.xiang@teradata.com
Reply: user@zookeeper.apache.org user@zookeeper.apache.org
Date: June 9, 2014 at 12:42:49 PM
To: zookeeper-user@hadoop.apache.org zookeeper-user@hadoop.apache.org
Subject: Re: How to set a watch for a deletion of a node?
The thing is I don't want to set a watch on that particular child node. I am
using the parent node as a container table and I would like to be notified
through a Watch mechanism any of my child is being deleted and which child
is that (via a node path).
That way I don't have to set a watch for each child node when it is getting
created and I can track it on the parent node level only.
Isn't there a way to get around this please?
Thanks for the hints,
Yang
--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/How-to-set-a-watch-for-a-deletion-of-a-node-tp7579974p7579976.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Re: How to set a watch for a deletion of a node?
Posted by xytd <ya...@teradata.com>.
The thing is I don't want to set a watch on that particular child node. I am
using the parent node as a container table and I would like to be notified
through a Watch mechanism any of my child is being deleted and which child
is that (via a node path).
That way I don't have to set a watch for each child node when it is getting
created and I can track it on the parent node level only.
Isn't there a way to get around this please?
Thanks for the hints,
Yang
--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/How-to-set-a-watch-for-a-deletion-of-a-node-tp7579974p7579976.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Re: How to set a watch for a deletion of a node?
Posted by "James A. Robinson" <ji...@highwire.org>.
You can just set a getData or exists watch on the node you are interested
in.
>From the documentation at
http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html:
getData() and exists() return information about the data of the node,
whereas getChildren() returns a list of children. Thus, setData() will
trigger data watches for the znode being set (assuming the set is
successful). A successful create() will trigger a data watch for the
znode being created and a child watch for the parent znode. A
successful delete() will trigger both a data watch and a child watch
(since there can be no more children) for a znode being deleted as
well as a child watch for the parent znode.
On Mon, Jun 9, 2014 at 10:20 AM, xytd <ya...@teradata.com> wrote:
>
>
> Is there way to watch for a deletion of a child node? The callback thus
> contains the node path which is being deleted.
>
> The only way I would see it to work is to load a list of the children and
> when a ChildrenWatch gets triggered, use it to compare with the list of
> children returned. But this is not very intuitive. There must be a better
> way to do this?
>
> Thanks for any suggestion,
>
> Yang
>
>
>
>
> --
> View this message in context: http://zookeeper-user.578899.n2.nabble.com/How-to-set-a-watch-for-a-deletion-of-a-node-tp7579974.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.