Recent contact Zookeeper, useful to part of the function, so here is a simple record:
Monitoring of events in curator
The native Zookeeper event listener is implemented with watcher, but watcher monitoring is a one-time, and must be re-registered if the event needs to continue to be monitored.
The cache is used in curator to encapsulate the interception of events, encapsulating 3 types of event snooping in packet Org.apache.curator.framework.recipes.cache.
The cache is divided into three types (in fact, from different dimensions to parse the cache):
1.PathChildrenCache cache listens on a path, a znode child node
2.node cache listens to a node
3.tree Cache listener nodes and the status of child nodes, monitoring nodes in the entire tree
Add event monitoring via AddListener, monitor changes, and provide interfaces to facilitate the implementation of relevant changes.
See for example:
http://colobu.com/2014/12/15/zookeeper-recipes-by-example-5/
http://090508tanjie.iteye.com/blog/2288256
http://my.oschina.net/jiangzhixiong/blog/537706
Event monitoring--cache in zookeeper