本文小结下Zookeeper中4种数据事件(ZOO_CHANGED_EVENT, ZOO_CHILD_EVENT, ZOO_CREATED_EVENT, ZOO_DELETED_EVENT)的触发条件。
如下表所示:
| 事件 | 触发条件 | Watcher设置函数 |
| ZOO_CHANGED_EVENT | only generated by watches on nodes | zoo_exists / zoo_get |
| ZOO_CHILD_EVENT | only generated by watches on the child list of a node | zoo_get_children / zoo_get_children2 |
| ZOO_CREATED_EVENT | only generated by watches on the child list of a node | zoo_exists |
| ZOO_DELETED_EVENT | only generated by watches on nodes | zoo_exists / zoo_get |