Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B517EED03 for ; Wed, 23 Jan 2013 12:12:51 +0000 (UTC) Received: (qmail 14011 invoked by uid 500); 23 Jan 2013 12:12:51 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 13503 invoked by uid 500); 23 Jan 2013 12:12:46 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 13479 invoked by uid 99); 23 Jan 2013 12:12:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 12:12:45 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jonsmith@mail.com designates 74.208.4.201 as permitted sender) Received: from [74.208.4.201] (HELO mout.gmx.net) (74.208.4.201) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 12:12:35 +0000 Received: from mailout-us.mail.com ([172.19.198.49]) by mrigmx.server.lan (mrigmxus001) with ESMTP (Nemesis) id 0LZynp-1TCK2K2KYn-00lp95 for ; Wed, 23 Jan 2013 13:12:13 +0100 Received: (qmail invoked by alias); 23 Jan 2013 12:12:13 -0000 Received: from mail-pb0-f43.google.com (EHLO mail-pb0-f43.google.com) [209.85.160.43] by mail.gmx.com (mp-us009) with SMTP; 23 Jan 2013 07:12:13 -0500 X-Authenticated: #76452973 X-Provags-ID: V01U2FsdGVkX1/1wlV94BH1nqpyu9StJ6cIt3YrxxrslGBXUVXV2C lMrKm1iP6EsJzg Received: by mail-pb0-f43.google.com with SMTP id jt11so3282691pbb.30 for ; Wed, 23 Jan 2013 04:12:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:date:message-id:subject :from:to:content-type:content-transfer-encoding:x-gm-message-state; bh=JPxxrUm8z07s6quC3mh3qotaQQOFYYUbRo2E3vYta9o=; b=ZOJv+g1a+hXcmKPPJHf3/Usxc97OlfqoTSr0jy/vVTiUmEhWr3CE9bN7EPRhLXXqQj 6NXhW9qSq+qtG5hFtIEZAexHNET0zL2tlyns9unwM9QJqM3IK6vijuG/EenltJMUR2GY wXf6ziJPdfW8R1EOou2/0ccmE6KRCMtFy7NlJ72v/DlZNlW0U7W9a2736mc7GMNti1hm cl/5gN5mCuYcU5nFw2bk3QrpmZm7iCmXdzz9o/WfjjV/POR23xenGKWjOHqlpEK2K97g EwZz+xF6M3duNJ5Rmuy9/LtNhgKr3gJWs+xMWl0bPWgOuPazXFqi6/hZNkeg3ENuIjN2 ZFiQ== MIME-Version: 1.0 X-Received: by 10.68.233.197 with SMTP id ty5mr3140488pbc.9.1358943132281; Wed, 23 Jan 2013 04:12:12 -0800 (PST) Received: by 10.68.143.98 with HTTP; Wed, 23 Jan 2013 04:12:12 -0800 (PST) X-Originating-IP: [82.132.245.146] Date: Wed, 23 Jan 2013 12:12:12 +0000 Message-ID: Subject: =?windows-1252?Q?ZooKeeper_Watch_triggered_multiple_times_for_the_sam?= =?windows-1252?Q?e_notification_=96_contrary_to_docs?= From: Jonathan Smith To: user@zookeeper.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnB0LAbRXW6OqbT/GBEW+f61TTR8KwcbGg++L+bZyC10h1nIPoVBqnRiaj6QBLJjM9LSvJy X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org I have a node that has a children watch on it. Whenever the NodeChildrenChanged event is received I obtain the children using getChildren passing in my watcher then iterate through all children and perform a getData() also passing in my watcher so that I am also notified of any changes to the data on the children. E.g. public void check() { List children =3D zkclient.getChildren().usingWatcher(myWatcher).forPath(PATH); for (String name : children) { byte[] data =3D zkclient.getData().usingWatcher(myWatcher).forPath(getPathFromName(name)); // do stuff } } CuratorWatcher myWatcher =3D new CuratorWatcher() { @Override public void process(WatchedEvent event) throws Exception { logger.info("received watch event: " + event); if (event.getType().equals(EventType.NodeChildrenChanged) || event.getType().equals(EventType.NodeDataChanged)) { check(); } } }; This means that whenever a child is added/removed, another getData call will be made with the watcher. After reading the ZooKeeper documentation I thought it would be fine to keep setting the watcher since I should only be given the same watch notification once: =93A watch object, or function/context pair, will only be triggered once for a given notification. For example, if the same watch object is registered for an exists and a getData call for the same file and that file is then deleted, the watch object would only be invoked once with the deletion notification for the file.=94 http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#ch_zkWatche= s However I have observed that when a node is deleted I am receiving the NodeDeleted watch event multiple times: received watch event: WatchedEvent state:SyncConnected type:NodeDeleted path:/a/b received watch event: WatchedEvent state:SyncConnected type:NodeDeleted path:/a/b received watch event: WatchedEvent state:SyncConnected type:NodeDeleted path:/a/b ... This means the watch is being triggered multiple times unnecessarily. I am using the Curator framework however I believe this just passes the watches through and therefore this is a ZooKeeper issue. I am using zookeeper server version 3.4.5, zookeeper client 3.3.1, curator-framework 1.2.2. Is the documentation wrong / is this a bug or have I misunderstood? Many thanks, Jon