Working with znodes (Zookeeper Nodes) and their Properties

What is a znode?

In Apache ZooKeeper, a znode represents a node in the ZooKeeper data model, and it is similar to a file or directory in a file system. Just like files and directories can be organized in a hierarchical structure, znodes are organized in a hierarchical tree-like structure as well.

Types of znodes

There are two types of znodes in ZooKeeper:

  1. Regular znodes: These are the nodes that store data along with their paths in the ZooKeeper hierarchy. They can have children znodes, making it possible to create a hierarchical structure.

  2. Ephemeral znodes: These are temporary nodes that exist as long as the session that created them is active. When the session ends, the ephemeral znodes are automatically deleted. Ephemeral znodes are useful for scenarios where temporary or dynamic information needs to be stored.

Working with znodes

To work with the znodes in ZooKeeper, a client needs to connect to the ZooKeeper ensemble and establish a session. Once the session is established, various operations can be performed on the znodes, such as creating, reading, updating, and deleting znodes.

Creating a znode

To create a znode, a client can use the create command with the desired path and data. The path can be either absolute or relative to the current working directory.

create /myznode "Hello World!"

This command will create a regular znode named "myznode" with the given data "Hello World!".

Reading data from a znode

To read the data from a znode, the get command can be used with the path of the znode.

get /myznode

This command will display the data stored in the znode "myznode".

Updating data in a znode

To update the data in a znode, the set command can be used with the path of the znode and the new data.

set /myznode "New Data"

This command will update the data of the znode "myznode" with the new data "New Data".

Deleting a znode

To delete a znode, the delete command can be used with the path of the znode.

delete /myznode

This command will delete the znode "myznode" from the ZooKeeper ensemble.

Znode properties

Each znode in ZooKeeper has certain properties associated with it, including:

  1. Path: The hierarchical path of the znode in the ZooKeeper ensemble.

  2. Data: The data associated with the znode, which can be any binary data.

  3. Version: The version number of the znode, which is incremented every time the znode is modified.

  4. Children: The list of child znodes under a regular znode.

  5. ACL (Access Control List): The access control list for the znode, which determines who can perform operations on the znode.


Zookeeper nodes, also known as znodes, are an essential component of Apache ZooKeeper. They represent nodes in the ZooKeeper data model and can store data along with their paths. Regular znodes can be organized hierarchically, while ephemeral znodes are temporary and are automatically deleted when the session ends. Working with znodes involves creating, reading, updating, and deleting operations. Each znode in ZooKeeper has properties like path, data, version, children, and ACL, which provide additional information and control over the znode. Understanding znodes and their properties is crucial for effectively utilizing ZooKeeper in distributed systems.

noob to master © copyleft