Understanding of zookeeper watch mechanism

First, let's see why we add a watch.

Zookeeper is a service used to coordinate (synchronize) distributed processes. It provides a simple high-performance coordination kernel on which users can build more complex distributed coordination functions.

Multiple distributed processes operate the shared zookeeper memory data object znode through the API provided by zookeeper to reach a certain consistent behavior or result. This mode is essentially a concurrency model based on state sharing, which is consistent with the multi-threaded concurrency model of Java. Their threads or processes are "shared memory communication". Java does not directly provide a responsive notification interface to monitor the change of the state of an object. It can only waste CPU time and unresponsive polling and retry, Or based on some kind of active notification mechanism (built-in queue) provided by java to respond to state changes, but this mechanism requires circular blocking calls, and zookeeper implements the state of these distributed processes When sharing (data and children of znode), based on performance considerations, a similar asynchronous non blocking active notification mode, i.e. watch mechanism, is adopted to make the "shared state communication" between distributed processes more real-time and efficient. In fact, this is also the coordination determined by zookeeper's main task.

The above is all about the zookeeper watch mechanism in this article. Interested friends can refer to: configuring corresponding ACL permissions for zookeeper, detailed examples of Apache zookeeper usage methods, etc. I hope it will be helpful to you.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>