Database Reference
In-Depth Information
The ZooKeeper Service
ZooKeeper is a highly available, high-performance coordination service. In this section, we
look at the nature of the service it provides: its model, operations, and implementation.
Data Model
ZooKeeper maintains a hierarchical tree of nodes called znodes. A znode stores data and
has an associated ACL. ZooKeeper is designed for coordination (which typically uses
small datafiles), not high-volume data storage, so there is a limit of 1 MB on the amount of
data that may be stored in any znode.
Data access is atomic. A client reading the data stored in a znode will never receive only
some of the data; either the data will be delivered in its entirety or the read will fail. Simil-
arly, a write will replace all the data associated with a znode. ZooKeeper guarantees that
the write will either succeed or fail; there is no such thing as a partial write, where only
some of the data written by the client is stored. ZooKeeper does not support an append op-
eration. These characteristics contrast with HDFS, which is designed for high-volume data
storage with streaming data access and provides an append operation.
Znodes are referenced by paths, which in ZooKeeper are represented as slash-delimited
Unicode character strings, like filesystem paths in Unix. Paths must be absolute, so they
must begin with a slash character. Furthermore, they are canonical, which means that each
path has a single representation, and so paths do not undergo resolution. For example, in
Unix, a file with the path /a/b can equivalently be referred to by the path /a/./b because “.”
refers to the current directory at the point it is encountered in the path. In ZooKeeper, “.”
does not have this special meaning and is actually illegal as a path component (as is “..” for
the parent of the current directory).
Path components are composed of Unicode characters, with a few restrictions (these are
spelled out in the ZooKeeper reference documentation). The string “zookeeper” is a re-
served word and may not be used as a path component. In particular, ZooKeeper uses the
/zookeeper subtree to store management information, such as information on quotas.
Note that paths are not URIs, and they are represented in the Java API by a
java.lang.String , rather than the Hadoop Path class (or the java.net.URI
class, for that matter).
Znodes have some properties that are very useful for building distributed applications,
which we discuss in the following sections.
Search WWH ::




Custom Search