zookeeper 节点信息解读

本文主要记录一个zookeeper node详细信息的各项参数的含义

官方文档: ZooKeeper Stat Structure

参数 解释 中文解读
czxid The zxid of the change that caused this znode to be created. 修改这个节点时的zxid号
mzxid The zxid of the change that last modified this znode. 修改这个节点时的zxid号
pzxid The zxid of the change that last modified children of this znode. 修改这个节点给它添加子节点时的zxid号
ctime The time in milliseconds from epoch when this znode was created. 节点的创建时间
mtime The time in milliseconds from epoch when this znode was last modified. 节点的修改时间
version The number of changes to the data of this znode. 节点变更的版本号
cversion The number of changes to the children of this znode. 该节点的子节点的更新次数
aversion The number of changes to the ACL of this znode. 这个节点的ACL的变更次数
ephemeralOwner The session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero. 如果是临时节点,那么创建这个节点的session id号
dataLength The length of the data field of this znode. 这个节点的数据的长度
numChildren The number of children of this znode. 这个节点的子节点数量

代码演示

[zk: localhost:2181(CONNECTED) 3] create /p1 thinktik
Created /p1
[zk: localhost:2181(CONNECTED) 4] stat /p1
cZxid = 0x58
ctime = Mon Feb 15 23:42:57 CST 2021
mZxid = 0x58
mtime = Mon Feb 15 23:42:57 CST 2021
pZxid = 0x58
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0 # 非临时节点的值固定为0x0,临时节点会有seesion id
dataLength = 8   # 该节点的长度为为8,也是就thinktik的长度
numChildren = 0  # 子节点个数为0
[zk: localhost:2181(CONNECTED) 5] create /p1/s1 think
Created /p1/s1
[zk: localhost:2181(CONNECTED) 6] stat /p1
cZxid = 0x58
ctime = Mon Feb 15 23:42:57 CST 2021
mZxid = 0x58
mtime = Mon Feb 15 23:42:57 CST 2021
pZxid = 0x59 # 子节点被创建时的zxid
cversion = 1 # 子节点修改了1次
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 1 # 子节点个数为1
[zk: localhost:2181(CONNECTED) 11] create /p1/s2 think2
Created /p1/s2
[zk: localhost:2181(CONNECTED) 12] stat /p1
cZxid = 0x58
ctime = Mon Feb 15 23:42:57 CST 2021
mZxid = 0x58
mtime = Mon Feb 15 23:42:57 CST 2021
pZxid = 0x5c
cversion = 2  # 子节点修改了2次
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 2  # 子节点个数为2

实际上的官方文档和代码演示有细微的区别,但是区别不大

本文原创链接: zookeeper 节点信息解读

你可能感兴趣的:(zookeeper)