Easy Tutorial
❮ Javascript Search Auto Tip Verilog Assign ❯

5.0 ZooKeeper Data Model: Detailed Structure of znode

Category Zookeeper Tutorial

Data Model

In Zookeeper, it can be said that all stored data is composed of znodes, which are also referred to as nodes and store data in key/value format.

The overall structure is similar to the Linux file system, stored in a tree-like structure, with the root path starting with /.

$ ls /
$ ls /zookeeper
$ ls /zookeeper/quota

We can intuitively see that the stored data currently exists under the root directory with two nodes: tutorialpro and zookeeper, and under the zookeeper node, there is a quota node.

The tutorialpro node was created in a previous section and set to a value of 0 via a Java client. Now, we execute get /tutorialpro in the command line terminal to display the attributes of this node.

$ get /tutorialpro

The first line showing 0 is the value of this node.

Znode Status Attributes

cZxid Transaction ID when the node was created
ctime Time when the node was created
mZxid Transaction ID of the last modification to the node
mtime Time of the last modification to the node
pZxid Transaction ID of the last modification to the list of child nodes of this node. Adding or deleting child nodes affects the list of child nodes, but modifying the data content of child nodes does not affect this ID (Note: only changes to the list of child nodes will change pzxid, changes to the content of child nodes will not affect pzxid)
cversion Version number of child nodes, incremented by 1 with each modification of child nodes
dataversion Version number of data, incremented by 1 with each modification of data
aclversion Version number of permissions, incremented by 1 with each modification of permissions
ephemeralOwner SessionID of the session that created this ephemeral node. (If this node is persistent, this attribute value is 0)
dataLength Length of the data in this node
numChildren Number of child nodes this node has (only counts direct child nodes)

Understanding the above status attributes, we modify the /tutorialpro node by executing the command set /tutorialpro 1, as shown below:

$ set /tutorialpro 1

Comparing the results, we can see that mZxid, mtime, and dataVersion have all changed.

Under the /tutorialpro node, we add a child node by executing:

$ create -e  /tutorialpro/child  0
$ get /tutorialpro

Note: More commands will be detailed in later chapters.

After executing the terminal command line displays:

We can see that the pZxid, cversion, and numChildren of the /tutorialpro node have changed accordingly.

-1.0 Zookeeper Tutorial

-2.0 Zookeeper Installation and Configuration

-3.0 Zookeeper Linux Server Cluster Setup Steps

-4.0 Zookeeper Java Client Setup

-6.0 Zookeeper Session Basic Principles

-7.0 Zookeeper Basic Command Usage

-8.0 Zookeeper Four-Letter Commands

-9.0 Zookeeper Node Features

-10.0 Zookeeper Access Control ACL

-11.0 Zookeeper Watcher Event Mechanism Analysis

-12.0 Zookeeper Data Synchronization Process

-13.0 Zookeeper Leader Election Principles

-14.0 Zookeeper Distributed Lock Implementation Principles

WeChat Subscription

❮ Javascript Search Auto Tip Verilog Assign ❯