Database Reference
In-Depth Information
Watches and Notifications
The primary use case for ZooKeeper involves waiting for events, which are
changes todata associated with a znode orwith thechildren ofthe znodes .
Rather than using polling, ZooKeeper uses a notification system to inform
clients of changes.
This notification, called a watch , is established when the application
registers itself with ZooKeeper to be informed of changes on a particular
znode path. This is a one-time operation, so when the notification is fired,
the client must reregister the watch to receive future notifications about
changes.
When attempting to continuously monitor a path, it is possible to lose a
notification.Thiscanoccurwhenachangeismadetoapathinthetimeafter
the client receives the notification of a change but before setting a watch
for the next notification. Fortunately, ZooKeeper's designers anticipated
this scenario, and setting a watch also reads data from the znode . This
effectively allows clients to coalesce notifications.
Maintaining Consistency
ZooKeeper does not employ the Paxos' consensus algorithm directly.
Instead it uses an alternative algorithm called Zab, which was intended to
offer performance improvements over the Paxos algorithm.
The Zab algorithm operates on the order of changes to state as opposed to
the Paxos algorithm that updates the entire state when changes are made.
That said, it shares many of the same features as Paxos: A Leader goes
through a Proposal process, accepting acknowledgment from a quorum of
recipients before committing the proposal. The algorithm also uses a
counter system, called an epoch number, similar to the one employed by
Paxos.
Creating a ZooKeeper Cluster
ZooKeeper is envisioned as a shared service, acting as a common resource
for a number of different applications. It uses a quorum of machines to
maintain high availability. One of these machines will be declared the
Leader using the Zab algorithm described in the previous section and all
changes will be replicated to the other servers in the quorum. This section
Search WWH ::




Custom Search