2
votes

The Watches of Zookeeper are one time triggers; if I get a watch event and I want to get notified of future changes, I must set another watch.

There are some disadvantages:

1) That makes my code complex

2) There is latency between getting the event and sending a new request to get a watch,some changes may be missed!

Why does Zookeeper make Watches one time triggers?

1

1 Answers

2
votes

You can see [ZOOKEEPER-153][1] https://issues.apache.org/jira/browse/ZOOKEEPER-153

In reality such permanent watches do not provide any extra benefit over one time watches. Specifically, no data is included in a watch event, so the client still needs to do a query operation to get the data corresponding to a change; even then, the znode can change yet again after the event is received and before the client sends the query operation. Even the number of of changes to a znode can be found using one time watches and checking the mzxid in the stat structure of the znode. And the client will still miss events that happen when the client switches ZooKeeper servers.