ZooKeeper学习笔记

ZooKeeper主要有三类功能

ZooKeeper Data Model   -------->   

ZNodes,Time in ZooKeeper , ZooKeeper  Stat Structure

Znodes

ZooKeeper 中每一个node都对应一个znode

znode维护着数据的version numbers for data changes acl changes

version numbers 在每次data发生变化时都会自动增长。

znode是程序操作的实体。操作有如下几种

Watches         client可以为znode设置Watches

Data Access     可以原子性的读取znode的数据

znode 存放的数据不易过大

Time in ZooKeeper 

ZooKeeper tracks time multiple ways

Zxid  , Version numbers  ,  Ticks  ,  Real time

ZooKeeper Stat Structure

czxid  , mzxid  , pzxid  ,  ctime   ,  mtime  ,  version  ,  cversion  ,  aversion   ,  ephemeralOwner  ,  dataLength  , numChildren


ZooKeeper Sessions

自动保持,检测,重连,更换,负载均衡 连接及session信息



ZooKeeper Watches

1. one-time trigger  每个watches只会触发一次,除非再次创建watches

2.sent to the client  ZooKeeper会保证client感知到data changge的顺序

3.the data for which the watch was set.   getData ()   exists() set data watches。getchildren() sets child watches.

触发watches的事件

  • Created event:

    Enabled with a call to exists.

  • Deleted event:

    Enabled with a call to exists, getData, and getChildren.

  • Changed event:

    Enabled with a call to exists and getData.

  • Child event:

    Enabled with a call to getChildren.

删除watches

  • Child Remove event:

    Watcher which was added with a call to getChildren.

  • Data Remove event:

    Watcher which was added with a call to exists or getData.

ZooKeeper会保证Watches触发的顺序

client在看到新数据之前,会先看到对应Watches

watches的顺序和数据更新顺序一致

ZooKeeper access control using ACLs


ZooKeeper supports the following permissions:

  • CREATE: you can create a child node

  • READ: you can get data from a node and list its children.

  • WRITE: you can set data for a node

  • DELETE: you can delete a child node

  • ADMIN: you can set permissions

ZooKeeper Gurantees



ZooKeeper java Example




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值