欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Watcher事件类型(一)

程序员文章站 2022-05-14 22:56:18
...
  • 创建父节点触发:NodeCreated
[zk: localhost:2181(CONNECTED) 16] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 17] stat /imooc watch
Node does not exist: /imooc
[zk: localhost:2181(CONNECTED) 18] create /imooc
[zk: localhost:2181(CONNECTED) 19] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 20] create /imooc 123

WATCHER::

WatchedEvent state:SyncConnected type:NodeCreated path:/imooc
Created /imooc

  • 修改父节点数据触发:NodeDataChanged
[zk: localhost:2181(CONNECTED) 22] get /imooc watch 
456
cZxid = 0x200000005
ctime = Tue Oct 23 11:10:28 CST 2018
mZxid = 0x200000006
mtime = Tue Oct 23 11:11:45 CST 2018
pZxid = 0x200000005
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 3
numChildren = 0
[zk: localhost:2181(CONNECTED) 23] set /imooc 789  

WATCHER::

WatchedEvent state:SyncConnected type:NodeDataChanged path:/imooc
cZxid = 0x200000005
ctime = Tue Oct 23 11:10:28 CST 2018
mZxid = 0x200000007
mtime = Tue Oct 23 11:12:14 CST 2018
pZxid = 0x200000005
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 3
numChildren = 0

  • 删除父节点触发:NodeDeleted
[zk: localhost:2181(CONNECTED) 24] get /imooc watch
789
cZxid = 0x200000005
ctime = Tue Oct 23 11:10:28 CST 2018
mZxid = 0x200000007
mtime = Tue Oct 23 11:12:14 CST 2018
pZxid = 0x200000005
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 3
numChildren = 0
[zk: localhost:2181(CONNECTED) 25] delete /imooc

WATCHER::

WatchedEvent state:SyncConnected type:NodeDeleted path:/imooc

相关标签: Zookeeper