设为首页 收藏本站
查看: 627|回复: 0

[经验分享] zookeeper-3.5--1.summary

[复制链接]

尚未签到

发表于 2017-4-19 09:37:06 | 显示全部楼层 |阅读模式
  here will talk about the skeleton model of zookeeper,so the details of implemention are recommanded to dig into sources.
  I startup 
  1.1 client side
  1.2 server side
  ------
  I startup 
  1.1 client side
  as u can see,through the client shell entry,the zkCli.sh states that the  class 'ZooKeeperMain' is the real client command side interacted with server,and the class 'ZooKeeper' is an ensucapsuated client tools which is more closed to server .
  here is a simple client side handling model
  
DSC0000.png
   so u will know that there are two components in ZooKeeper instance:
  1.SendThread--used to interact wth server,include send packet to and receive result response from server.in general the ClientCnxnSocketNIO is the implemented class of cnxn.so this is a 'flow controller class'
  2.EventThread--delivers events from the queue which has been put in element in the reponse of SendThread to user register watcher.
  so here are some questions to ask normally:
  q1:if i do some heavy tasks in Watcher#process() ,will it affect   the server?
  no,as this process is stayed in client side,so if u want to issue some CRUD ops about zk or ther io heavy ops ,please go ahead.
  q2:if more than one clients registered  watchers at the same znode(path) ,which one will will be notified first,certain order?
  the notification order is not guaranteed,as the server will send back a notification to all clients whcih have registerd the znode concurrently ,so the order will be caslled as 'randomly'.see 1.2 server side(also,FinalReqeustProcessor#process() & NIOServerCnxn#processWatch())
  q3:issue a 'delete' op on zookeeper client,which one will come first,this  result response or event triggers registered before?
  same as q2,as all reponses will be sent concurrently,so no order is guaranteed.
  1.2 server side
  from the zkServer.sh we know that the 'QuorumPeerMain' is the entry of server side. 
  1.2.1 standalone mode
  
DSC0001.png
  note:the WorkerThread will not exist if the # of workers is undefined or set to 0.and the NIOServerCnxn is resonsible for communicating with clients to read data from or write data to.
  client A--a client that issue certain CRUD ops.
  clients B--certain clients registered wathchers on that znode,so they will be nodified when client A ops are complete.
  and the request processor chains are below(only for standalone mode):
  
DSC0002.png
  for example,client B commit a 'getData' op on a znode with a watcher,then server will keep in mind this cnxn;then when client A post a 'delete' op on the same znode,the server will know who has registered this znode,so after the znode has been removed in server,than a 'notification' will be sent to client B immediately.
  but one thing i want to know is:for a 'read' op,the client will get 2 times(two selected keys) to complete the reading;but   only one selected-key for server to do that,why?(preliminarily suggest that this is a nio mechanism,right?) give me a clue if you have any thinkings,please
  something to keep in mind:
  A.the client will adjust sessionTimeout against the server's bounds
  in ZooKeeper(x,x),we will pass a sessionTimeout param,and generate two sessionTimeout values against it:

connectTimeout = sessionTimeout / num-zk-servers-client-want-to-connect
readTimeout = sessionTimeout * 2  / 3
  but after the first connect to server,the server will fix it by apply bouds:

minSessionTimeout < sessionTimeout-in-cient < maxSessionTimeout
  and the maxSessionTimeout bound will be applied after the min.

minSessionTimeout  = 2*tick;maxSessionTimeout = 20 * tick
  of course the sub values 'connectTimeout' and 'readTimeout' will be recomputed also.
  B.there is a sesssion expiry thread called 'SessionTrackerImpl' to expire those
  this thread will use a bucket to remove batch expired threads by using fixed sessionTimeout described in A above,so the real expiry time is not absoulte exact,but it's not important.so the param 'sessionTimeout' sent from client is used only by server for checking expiry period,but no anywhere fro client.
  if u want to introduce a timeout concept in client,u can check in 高并发下NIO socket消息超时机制的探讨 or use a new nio framework,e.g mina
  1.2.2 ensemble mode     

         zookeeper-3.5--2 ensemble work flow

   
  ref:


zookeeper-3.5--study flow 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-366194-1-1.html 上篇帖子: 分布式助手Zookeeper(七) 下篇帖子: zookeeper系列之数据模型
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表