<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ZAB on Zhuifeng Notes</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tags/zab/</link><description>Recent content in ZAB on Zhuifeng Notes</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 25 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://4f0a9a3b.wangpeng.pages.dev/en/tags/zab/index.xml" rel="self" type="application/rss+xml"/><item><title>ZooKeeper Data Model and the ZAB Protocol</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tech/zookeeper/model-zab/</link><pubDate>Tue, 25 Aug 2026 00:00:00 +0000</pubDate><guid>https://4f0a9a3b.wangpeng.pages.dev/en/tech/zookeeper/model-zab/</guid><description>&lt;p&gt;ZooKeeper&amp;rsquo;s reliability comes from its simple data model and the strongly-consistent ZAB protocol. Understanding both is a prerequisite for using ZK correctly.&lt;/p&gt;&#10;&lt;h2 id="the-znode-data-model"&gt;The znode Data Model&#10;&lt;/h2&gt;&#10;&lt;p&gt;ZK maintains a hierarchical tree similar to a file system; each node is a &lt;strong&gt;znode&lt;/strong&gt; that can hold both data and children. Its type determines lifecycle and concurrency semantics:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Persistent / Ephemeral&lt;/strong&gt;: ephemeral nodes are auto-deleted when the session disconnects, forming the basis of distributed locks and leader election.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Plain / Sequential&lt;/strong&gt;: sequential nodes get a monotonically increasing sequence number appended on creation.&lt;/li&gt;&#10;&lt;li&gt;Each znode carries &lt;code&gt;version&lt;/code&gt;, &lt;code&gt;cversion&lt;/code&gt;, &lt;code&gt;aversion&lt;/code&gt;; versions increment on modification, providing optimistic-lock semantics.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="session-and-watcher"&gt;Session and Watcher&#10;&lt;/h2&gt;&#10;&lt;p&gt;A client establishes a &lt;strong&gt;session&lt;/strong&gt; with the server, kept alive via heartbeats. On session timeout the server cleans up its ephemeral nodes. A client can register a &lt;strong&gt;Watcher&lt;/strong&gt; on a node and receives a one-time notification when the node changes (data write, children change); it must re-register to keep watching.&lt;/p&gt;</description></item></channel></rss>