参考答案
- 调用 getData()/getChildren()/exist()三个 API,传入 Watcher 对象。
- 标记请求 request,封装 Watcher 到 WatchRegistration。
- 封装成 Packet 对象,发服务端发送 request。
- 收到服务端响应后,将 Watcher 注册到 ZKWatcherManager 中进行管理。
- 请求返回,完成注册。
以上,是Zookeeper面试题【客户端注册 Watcher 的实现过程】的参考答案。
输出,是最好的学习方法。
欢迎在评论区留下你的问题、笔记或知识点补充~
—end—
