zookeeper原理解析-服务器端处理流程(1)
- UID
- 1066743
|
zookeeper原理解析-服务器端处理流程(1)
1)处理器链
这部分内容我们主要讲解zookeeper请求在zookeeper server端的处理流程,对于不同角色的zookeeper具有不同的处理流程, ZookeepeerServer的start方法中会调用setupRequestProcessors()来初始化处理器链,它被子类覆写实现。
1. LeaderZooKeeperServer
看如上代码主要建立了如下的两个处理器流链
(1) PrepRequestProcessor(线程) => ProposalRequestProcessor(调initialize) =>CommitProcessor(线程) => Leader.ToBeAppliedRequestProcessor=>FinalRequestProcessor (2) ProposalRequestProcessor构造器设置另一处理器链, initialize方法启动SyncRequestProcessor线程 SyncRequestProcessor(线程)=> AckRequestProcessor
2. FollowerZooKeeperServer
看如上代码主要建立了如下的两个处理器流链
(1) FollowerRequestProcessor => CommitProcessor(线程) =>FinalRequestProcessor(线程) (2) SyncRequestProcessor(线程)=> SendAckRequestProcessor
3. ObserverZooKeeperServer
(1) ObserverRequestProcessor => CommitProcessor(线程) =>FinalRequestProcessor(线程)
(2) SyncRequestProcessor(线程)=> SendAckRequestProcessor (3) 看如上代码主要建立了如下的两个处理器流链
|
|
|
|
|
|