Zookeeper set watcher considerations for the specified node through the client __delete

Source: Internet
Author: User
Tags zookeeper zookeeper client zookeeper set

The zookeeper client can set watcher for a znode so that the client can obtain the appropriate event notification when the node changes. If you do not set the Watcher, you will not receive notification.


Taking zookeeper C client as an example, you can set the watcher flag at the same time when you call the following 3 functions, get the data or state of a node.

Zoo_exists//node exists. If the watcher is set, the node is deleted and the zoo_deleted_event is received, and the Zoo_created_event is received when the node is created.

Zoo_get//Get node data. If the watcher is set, the node data is changed and the Zoo_changed_event is received.

Zoo_get_children//Get a list of children's nodes. If set watcher, the child node number changes, receives zoo_child_event.

Attention:

1. Set a Watcher (can not be repeated settings, only the equivalent of setting up once) can only receive an event notification, then if the node changes again, will not be notified again, so every time after the event, need to reset the watcher node.

2. Zoo_exists can set watcher on nodes that have not yet been created, send created_event when nodes are created, or send deleted_event when a node is deleted.

3. Zoo_get,zoo_get_children cannot set watcher on a node that has not yet been created, and the watcher that was previously set is not valid after the node has been created.

(But after the node is created, if the Watcher is set through Zoo_esixts, the watcher previously Zoo_get settings appears to be valid)

4. Zoo_get, Zoo_get_children to the existence of the node set watcher, if the node is deleted, watcher will be invalidated, that is, after the node is recreated, the previously set watcher will become invalid.


Initialized path:/A
watched nodes

zoo_exists Zoo_get Zoo_get_children
Action Event /A /a/b /a/b/c Event /A /a/b /a/b/c Event /A /a/b /a/b/c
Create/a/b CREATED



Child
Create/a/b/c CREATED



Child X
Delete/a/b/c DELETED



Child X
Delete/a/b DELETED



Child
set/a data



CHANGED



Create/a/b CREATED



Child
set/a/b data



CHANGED



Create/a/b/c CREATED



Child X
SET/A/B/C data



CHANGED




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.