zk中的数据模型DataNode

有些话、适合烂在心里 提交于 2019-11-30 12:21:44

dataNode是数据存储的最小单元,保存节点数据内容,ACL控制列表,节点状态,父节点引用和子节点列表,同时也提供了子节点列表更新的方法

DataNode

属性
//节点签名,通过路径,数据,状态计算的long型数据
// the digest value of this node, calculated from path, data and stat
private volatile long digest;

// indicate if the digest of this node is up to date or not, used to
// optimize the performance.
volatile boolean digestCached;
//字节数组存储数据
/** the data for this datanode */
byte[] data;

/**acl long标识
 * the acl map long for this datanode. the datatree has the map
 */
Long acl;

/**datanode持久化的状态表示
 * the stat for this node that is persisted to disk.
 */
public StatPersisted stat;

/**子节点列表
 * the list of children for this node. note that the list of children string
 * does not contain the parent path -- just the last part of the path. This
 * should be synchronized on except deserializing (for speed up issues).
 */
private Set<String> children = null;
/**
 * 空set集合Collections.emptySet()
 */
private static final Set<String> EMPTY_SET = Collections.emptySet();



类关系图

 

StatPersisted类
属性
private long czxid;//节点创建时zxid
private long mzxid;//节点更新的zxid
private long ctime;//节点创建时间
private long mtime;//节点更新时间
private int version;//节点更新次数
private int cversion;//子节点的更新次数
private int aversion;//节点acl更新次数
private long ephemeralOwner;
private long pzxid;//子节点被最后更新的zxid

思考:

什么是zxid?

zxid包含两部分,the epoch and counter

64位数字

高32位用于epoch

低32位用于counter

递增唯一全局id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!