Zookeeper how to set up and get watcher correctly

Source: Internet
Author: User

Watcher Setup is the most common development, need to understand some of the basic characteristics of watcher, for exists, GetData, getchild for the different operations of the node will receive different watcher information

state=-112 Session Timeout Status
State=-113 Authentication failed status
State= 1 Connection Setup
State= 2 (temporarily unclear how to understand this state, zoo_associating_state)
STATE=3 Connection established status
state= 999 no Connection status


Type=1 Creating node Events
type=2 Deleting node events
Type=3 Changing node Events
Type=4 child Node List Change event
Type=-1 Sessions Session event
Type=-2 Monitoring removed events

Changes to the parent node and changes to the grandchild node do not trigger watcher, and changes to the watcher itself and child nodes trigger watcher, as specified in the following table.

Operation Method Trigger Watcher Watcher State Watcher Type Watcher Path
Create current node GetData X X X X
GetChildren 3 4
Exists X X X X
Set current node GetData 3 3
GetChildren X X X X
Exists 3 3
Delete current node GetData 3 2
GetChildren 3 2
Exists 3 2
Create child node GetData X X X X
GetChildren 3 4
Exists X X X X
Set child node GetData X X X X
GetChildren X X X X
Exists X X X X
Delete child node GetData X X X X
GetChildren 3 4
Exists X X X X
Restore connection GetData 1 -1 X
GetChildren 1 -1 X
Exists 1 -1 X
Restore connection session not timed out GetData -112 -1 X
GetChildren -112 -1 X
Exists -112 -1 X
Restore Connection Session Timeout GetData 3 -1 X
GetChildren 3 -1 X
Exists 3 -1 X

Note:x indicates no, √ indicates yes.
This article from the former CSDN blog, the full text address please click: 41726279?utm_source=copy

Zookeeper how to set up and get watcher correctly

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.