Zookeeper
LearnerHandler
There will be an instance of this class created by the Leader for each learner. All communication with a learner is handled by this class.
Leader上用于和learner通信
生产者消费者
ClientCnxn.EventThread
从waitingEvents读
ClientCnxn.SendThread
This class services the outgoing request queue and generates the heart beats. It also spawns the ReadThread.
向waitingEvents写
Watcher
This interface specifies the public interface an event handler class must implement. A ZooKeeper client will get various events from the ZooKeeper server it connects to. An application using such a client handles these events by registering a callback object with the client. The callback object is expected to be an instance of a class that implements Watcher interface.
客户端事件的基类
CommitProcessor
This RequestProcessor matches the incoming committed requests with the locally submitted requests. The trick is that locally submitted requests that change the state of the system will come back as incoming committed requests, so we need to match them up. Instead of just waiting for the committed requests, we process the uncommitted requests that belong to other sessions.
The CommitProcessor is multi-threaded. Communication between threads is handled via queues, atomics, and wait/notifyAll synchronized on the processor. The CommitProcessor acts as a gateway for allowing requests to continue with the remainder of the processing pipeline. It will allow many read requests but only a single write request to be in flight simultaneously, thus ensuring that write requests are processed in transaction id order.
负责读写请求
LeaderSessionTracker
The leader session tracker tracks local and global sessions on the leader.
线程名是 CommitProcessor
ZooKeeperServer
This class implements a simple standalone ZooKeeperServer.
SessionTracker
管理会话
RequestThrottler
限制请求数量 控制输入