Zookeeper Personal note node monitoring

Source: Internet
Author: User

Create
 Public string Create (string path,                     byte[] data,                     List<ACL> ACL,                     createmode Createmode)              throws  keeperexception,                     interruptedexception

1. Recursive creation of nodes is not supported, for example, if you are creating/master/a, you cannot create a (Keeperexception.nonode) if Master does not exist.

2. You can no longer create child nodes (keeperexception.nochildrenforephemerals) under a ephemeral type node.

3. If the specified node already exists, the keeperexception.nodeexists exception is triggered, of course the exception is not thrown for the sequential type.

4. The data content cannot exceed 1M, otherwise the keeperexception exception will be thrown.

For the entire life cycle of a Node A, there are several scenarios in which you can listen:

1. Successfully created Node A

2. Successful deletion of Node A

3. Node A data content has changed

4. The sub-list of Node A has changed

To be notified after a node is created, the client needs to register watcher in the Exists API.

Exists

This function is very special, because he can listen to a node that does not exist, this is Getdata,getchildren cannot do. Exists can monitor the life cycle of a node: from scratch, the node data changes from there to none.

In the watcher passed to exists, watcher receives a nodecreated event notification when the node specified by path is successfully created. When the data content of the node specified by path is changed, Wather is notified by the Nodedatachanged event.

 Public Stat exists (String path,                   Watcher watcher)            throws  keeperexception,                   null  If  no such a node exists. If the watch is non-null and the "Call is successful" (no exception is thrown), a watch would be Node with the given path. The watch would be triggered to a successful operation that creates/delete the node or sets the data on the node.

Returns the stat of the node specified by path, and returns null if the node does not exist. When this node is created, the contents of the data are modified, deleted, and all clients registered with the Watcher node will receive corresponding event notifications.

The most important thing to note here is that exists can listen to a nonexistent node, which is the difference between his nature and Getdata,getchildren.

GetData
 Public byte [] getData (String path,                      Watcher Watcher,                      stat stat)               throws  keeperexception,                      Interruptedexceptionreturn the data and the stat of the node of the given path. If the watchis a non-nullif no node with the given path exists.

GetData can also listen to a node, but if the node that he is listening to does not exist, a Keeperexception exception is thrown back and the error code for this exception is Nonode.

Watcher is only likely to be notified of events if the following two conditions are met:

1. When did this wacher be registered to the point specified in path? First you specify Watcher, and second, GetChildren does not throw any exceptions.

2. Watcher can receive notification when the node specified by path is successfully deleted.

A child list of the node specified by path successfully added or deleted a new node, and watcher will also receive a notification.

If the node specified by path does not exist, an exception is thrown.

GetChildren
 PublicList<string>GetChildren (String path,BooleanWatch)throwskeeperexception, Interruptedexceptionreturn the list of the children of the node of th e given path. If the Watch istrueAnd the call are successful (no exception is thrown), a watch would be was left on the node with the given path. The watch willbe triggered by a successful operation that deletes the node of the given path or creates/Delete a child under the node. The list of children returned are not sorted and no guarantee are provided as to their natural or lexical order. A keeperexception with error code Keeperexception.nonode would be thrownifNo node with the given path exists.

Watcher is only likely to be notified of events if the following two conditions are met:

1. When did this wacher be registered to the point specified in path? First you specify Watcher, and second, GetChildren does not throw any exceptions.

2. Watcher can receive notification when the node specified by path is successfully deleted.

The data content of the node specified by path changes, and watcher receives a nodechildrenchanged notification.

If the node specified by path does not exist, an exception is thrown.

Zookeeper Personal note node monitoring

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.