zookeeper 系列 官方翻译简介(四)

来源:互联网 发布:营口港数据 编辑:程序博客网 时间:2024/05/18 20:34
Nodes and ephemeral nodes
Unlike is standard file systems, each node in a ZooKeepernamespace can have data associated with it as well as children. Itis like having a file-system that allows a file to also be adirectory. (ZooKeeper was designed to store coordination data:status information, configuration, location information, etc., sothe data stored at each node is usually small, in the byte tokilobyte range.) We use the term znode to make it clear that we aretalking about ZooKeeper data nodes.

Znodes maintain a stat structure that includes version numbersfor data changes, ACL changes, and timestamps, to allow cachevalidations and coordinated updates. Each time a znode's datachanges, the version number increases. For instance, whenever aclient retrieves data it also receives the version of thedata.

The data stored at each znode in a namespace is read andwritten atomically. Reads get all the data bytes associated with aznode and a write replaces all the data. Each node has an AccessControl List (ACL) that restricts who can do what.

ZooKeeper also has the notion of ephemeral nodes. These znodesexists as long as the session that created the znode is active.When the session ends the znode is deleted. Ephemeral nodes areuseful when you want to implement [具体例子].

Conditional updates and watches
ZooKeeper supports the concept of watches. Clients can set awatch on a znodes. A watch will be triggered and removed when theznode changes. When a watch is triggered the client receives apacket saying that the znode has changed. And if the connectionbetween the client and one of the Zoo Keeper servers is broken, theclient will receive a local notification. These can be used to[tbd].

节点和临时节点
不像标准的文件系统,zookeeper 命名空间中的每个节点能够有数据关联,也有子节点.
就像文件系统一样,某个路径即可以是文件也可以是目录.(zookeeper被设计用来存储协调数据:
状态信息,配置信息,位置信息等等, 因此数据存储在每个节点中通常非常小,从几个字节到几千字节之间),
我们使用znode这个术语来使得我们讨论zookeeper数据节点时更加清晰明确.

znode管理着包含这一个状态结构数据,包含数据修改,ACL修改及时间戳的版本号, 允许缓存教育和协调更新.
每一次znode数据修改,版本号提升一次. 例如,无论何时客户端收到数据,同时都收到当前数据的版本.
每一个节点都有一个ACL访问控制列表,严格控制着谁能进行操作.
zookeeper也有会话级别的节点的语义支持,这些znode节点随着会话的创建而激活,会话的结束的时候节点被删除.
会话级别的节点在实现tbd的时候非常有用.

条件更新和监听
zookeeper支持监听, 客户端能够设置监听znode节点.当znode节点变更时可能触发或者移除监听.当监听事件被触发了,
客户端将会收到数据通知包,告诉客户端节点数据被修改了.同时如果当前客户端和zookeeper节点的连接被断开了.
客户端将收到一个本地通知. 这些特性都能用在 tbd 中  
0 0