`

zookeeper-3.5--1.summary

 
阅读更多

  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



   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


  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):

 

  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 

  • 大小: 109.4 KB
  • 大小: 83.2 KB
  • 大小: 15.3 KB
分享到:
评论

相关推荐

    apache-zookeeper(apache-zookeeper-3.7.1-bin.tar.gz)

    apache-zookeeper分布式框架,压缩包内容:(apache-zookeeper-3.7.1-bin.tar.gz、apache-zookeeper-3.7.1.tar.gz、apache-zookeeper-3.6.4-bin.tar.gz、apache-zookeeper-3.6.4.tar.gz、apache-zookeeper-3.5.10-...

    apache-zookeeper-3.5.7-bin.tar.gz

    1. **安装**:解压"apache-zookeeper-3.5.7-bin.tar.gz",配置环境变量,启动Zookeeper服务器。 2. **配置**:修改conf/zoo.cfg配置文件,设置数据存储目录、集群模式(standalone或ensemble)、端口号等参数。 3. *...

    apache-zookeeper-3.7.0-bin.tar.gz

    apache-zookeeper-3.7.0-bin.tar.gz

    zookeeper-3.4.10.tar.gz

    2. 修改配置文件:在`zookeeper-3.4.10/conf`目录下,有一个名为`zoo_sample.cfg`的示例配置文件,复制并重命名为`zoo.cfg`,这是ZooKeeper的主要配置文件。 3. 配置`zoo.cfg`: - `dataDir`:设置ZooKeeper的数据...

    zookeeper-3.4.12--.rar

    1. **Zookeeper 架构** ZooKeeper 的架构基于客户端-服务器模型。每个 ZooKeeper 集群由多个服务器节点组成,这些节点通过 zab(Zookeeper Atomic Broadcast)协议进行通信和数据同步,确保数据的一致性。客户端...

    apache-zookeeper-3.7.1-bin.tar.gz

    apache-zookeeper-3.7.1-bin.tar.gz 内容概要:通过带着读者手写简化版Spring框架,了解Spring核心原理。在手写Spring源码的过程中会摘取整体框架中的核心逻辑,简化代码实现过程,保留核心功能,例如:IOC, AOP、 Bean...

    apache-zookeeper-3.6.1-bin.tar.gz

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性...window下先解压为apache-zookeeper-3.6.1-bin.tar.gz

    zookeeper-3.4.5-cdh5.16.2.tar.gz

    《Zookeeper-3.4.5-cdh5.16.2:分布式协调服务的核心解析》 Apache ZooKeeper,一个高度可靠的分布式协调系统,是大数据生态中的重要组件。本资源包"zookeeper-3.4.5-cdh5.16.2.tar.gz"包含了Zookeeper的3.4.5版本...

    apache-zookeeper-3.6.3-bin.tar的压缩包,解压到本地即可使用,还有zk.sh的脚本以及zoo.cfg

    apache-zookeeper-3.6.3-bin.tar的压缩包,解压到本地即可使用,还有zk.sh的脚本以及zoo.cfg和xsync。ZooKeeper 是一个分布式协调服务 ,由 Apache 进行维护。ZooKeeper 可以视为一个高可用的文件系统。ZooKeeper ...

    apache-zookeeper-3.8.4-bin.tar

    1. 解压`apache-zookeeper-3.8.4-bin.tar`到指定目录。 2. 配置`conf/zoo.cfg`,设置服务器ID、数据存储路径、集群配置等。 3. 启动Zookeeper服务,使用`bin/zkServer.sh start`命令。 4. 使用`bin/zkCli.sh`命令行...

    zookeeper-3.4.11.tar.gz

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调...ZooKeeper代码版本中,提供了分布式独享锁、选举、队列的接口,代码在zookeeper-3.4.3\src\recipes。其中分布锁和队列有Java和C两个版本,选举只有Java版本。

    最新版linux apache-zookeeper-3.7.0-bin.tar.gz

    - 解压`apache-zookeeper-3.7.0-bin.tar.gz`到你选择的目录,例如 `/opt`. - 配置`conf/zoo.cfg`,设置数据目录(dataDir)和日志目录(dataLogDir),并根据需求调整其他配置。 - 初始化数据目录,创建myid文件...

    zookeeper-3.4.13.tar.gz 下载(5积分)

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是以Fast Paxos算法为基础,实现同步服务,配置维护和命名服务等分布式应用。而使用kafka前必须安装zookeeper。...(文件全称:zookeeper-3.4.13.tar.gz)

    zookeeper-3.4.5.jar zookeeper-3.4.5.jar

    zookeeper-3.4.5.jar; zookeeper-3.4.5.jar; zookeeper-3.4.5.jar;

    apache-zookeeper-3.6.2-bin.tar

    apache-zookeeper-3.6.2-bin.tar apache-zookeeper-3.6.2-bin.tar apache-zookeeper-3.6.2-bin.tar apache-zookeeper-3.6.2-bin.tar apache-zookeeper-3.6.2-bin.tar apache-zookeeper-3.6.2-bin.tar apache-...

    apache-zookeeper-3.5.5.tar.gz

    标题中的"apache-zookeeper-3.5.5.tar.gz"表明这是一个Apache ZooKeeper的版本3.5.5的归档文件,采用的是tar.gz格式,这是一种常见的Linux/Unix下的压缩方式,用于打包并压缩文件,便于下载和传输。 描述中提到...

    zookeeper-3.4.10.tar.gz.zip

    1. 解压`zookeeper-3.4.10.tar.gz`到指定目录,如`/opt/software`。 2. 配置`conf/zoo.cfg`,设置数据存储目录(dataDir)和其他参数。 3. 创建数据目录`mkdir /var/lib/zookeeper`并初始化myid文件,内容为当前...

    zookeeper-3.4.5-cdh5.15.1.tar.gz

    5. **集群部署**:如果需要搭建Zookeeper集群,需在所有节点上重复上述步骤,并在zoo.cfg中配置集群节点列表(server.1=ip1:port1:port2, server.2=ip2:port1:port2...)。 6. **客户端操作**:Zookeeper提供了...

    zookeeper-3.4.10-API文档-中文版.zip

    赠送jar包:zookeeper-3.4.10.jar; 赠送原API文档:zookeeper-3.4.10-javadoc.jar; 赠送源代码:zookeeper-3.4.10-sources.jar; 赠送Maven依赖信息文件:zookeeper-3.4.10.pom; 包含翻译后的API文档:zookeeper-...

    apache-zookeeper-3.5.10.7z下载

    在“apache-zookeeper-3.5.10.7z”这个压缩包中,包含了Zookeeper 3.7.1版本的服务端软件。这个版本可能包含了以下主要组成部分: 1. **bin** 目录:这个目录包含了Zookeeper的可执行文件和服务脚本,如 `zkServer....

Global site tag (gtag.js) - Google Analytics