这是一个ZooKeeper客户端,实现了断线重连,会话过期重连,永久监听,子节点数据变化的监听。并且加入了常用功能,例如分布式锁,Leader选举,分布式队列等。
![747fd012a5698d3f30162318c8a7b353.png](https://img-blog.csdnimg.cn/img_convert/747fd012a5698d3f30162318c8a7b353.png)
#使用说明
##一、创建ZKClient对象 有两种方式可以方便的创建ZKClient对象。
- 使用构造函数创建
String address = "localhost:2181"; ZKClient zkClient1 = new ZKClient(address); ZKClient zkClient2 = new ZKClient(address,500); ZKClient zkClient3 = new ZKClient(address,500,1000*60); ZKClient zkClient4 = new ZKClient(address,500,1000*60,new BytesSerializer()); ZKClient zkClient5 = new ZKClient(address,500,1000*60,new BytesSerializer(),Integer.MAX_VALUE); ZKClient zkClient6 = new ZKClient(address,500,1000*60,new BytesSerializer(),Integer.MAX_VALUE,2);
- 使用辅助类创建