ZooKeeper 源码解读
深入 Apache ZooKeeper 源码,探索分布式协调服务的底层实现。涵盖 ZAB 协议、Leader 选举、DataTree、Session 管理等核心机制。
文章
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:08. Watcher 监听机制
ZooKeeper Watcher 机制源码解析:一次性触发、WatcherManager 维护、客户端 WatcherSet 路径匹配与回调派发。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:10. Leader 选举 (FastLeaderElection)
ZooKeeper Leader 选举源码解析:FastLeaderElection 投票轮次、ZXID 与 myid 比较、QuorumServer 状态切换。
- 3 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:01. 环境搭建与源码编译
ZooKeeper 3.5+ 全面转向 Maven 构建,本文从 JDK / Maven 准备、源码获取、IDEA 导入到单机配置文件 zoo.cfg 逐步搭建可调试环境。
- 3 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:05. 持久化机制
ZooKeeper 持久化层源码解析:TxnLog 事务日志、Snapshot 快照、FileTxnSnapLog 协调、定时 fsync 策略。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:12. ZAB 协议:原子广播
ZooKeeper ZAB Broadcast 阶段源码解析:Proposal 提议、ACK 收集、Commit 应用、顺序保证与崩溃恢复。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:00. 阅读大纲与学习路线
Apache ZooKeeper 源码阅读系列大纲。从 ZAB 协议到 DataTree,从 Leader 选举到 Watcher 机制,全链路源码解析。
- 3 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:03. 启动流程详解
ZooKeeper Server 启动流程源码解析:配置文件解析、内存数据库初始化、选举启动、Leader/Follower 状态切换。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:07. Session 管理
ZooKeeper Session 管理源码解析:SessionTracker、SessionID 生成、过期检查(1/3 timeout)、临时节点清理。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:09. 请求处理链 (RequestProcessor)
ZooKeeper RequestProcessor 链路源码解析:PrepRequestProcessor → ProposalRequestProcessor → CommitProcessor 顺序。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:04. 数据模型 (DataTree)
ZooKeeper DataTree 源码解析:内存树形结构、DataNode 节点、ACL 与 Stat 属性、path 解析与 ZNode 操作。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:11. ZAB 协议:发现与同步
ZooKeeper ZAB Discovery 与 Sync 阶段源码解析:epoch 提议、TRX 差异比对、内存状态同步至 Follower。
- 3 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:06. 网络通信
解析 ZooKeeper 基于 NIO 的网络通信模型:CnxnFactory 抽象、AcceptThread + SelectorThread + WorkerThread 三层 Reactor 线程组,以及 ServerCnxn 的会话管理。
- 2 min read ZooKeeper 源码解读
ZooKeeper 源码阅读:02. 核心架构与模块概览
ZooKeeper 架构概览:文件系统 + 通知机制的数据模型、Leader/Follower/Observer 角色、ZXID 与 Zab 协议基础。