Katta如何使用Zookeeper-数据更新2

来源:互联网 发布:淘宝店铺皇冠和钻石 编辑:程序博客网 时间:2024/05/22 11:46
 
当Client连接到Follower,并发出数据更新的请求时:
1. Follower的CommitProcessor将阻塞Request,直到Leader发出Commit通知
2. Follower把数据更新的request转发给Leader,Leader然后发起数据更新同步的过程
具体如下图:
follower-update
注意:
Leader和Follower判断哪个最早接收到的数据更新请求,是根据Request属性中的ServerCnxn。
1. 当NIOServerCnxn接收到来自Client的请求后,就会在Request中设置本身的实例
2. 在ZkServer的当前实例中,Request的ServerCnxn是不变的
3. Follower发给Leader的请求中,ServerCnxn是null
4. Leader和Follower的FinalRequestProcessor发出响应时,判断ServerCnxn是否null:
实例类型ServerCnxn == nulltruefalseLeaderFollower发出,不发响应Leader接收到的,需要发出响应FollowerLeader发出,不发响应Follower接收到的,需要发出响应
原创粉丝点击