乐趣区

关于zookeeper: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 节点信息解读

退出移动版