一、ZkClient
ZkClient是由Datameer的工程师开发的开源客户端,对Zookeeper的原生API进行了包装,实现了超时重连、Watcher反复注册等功能。
maven依赖
<dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.9</version> </dependency> <dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> <version>0.10</version> </dependency> |
- zkclient使用
public ZkClient(String serverstring) public ZkClient(String zkServers, int connectionTimeout) public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout) public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout, ZkSerializer zk |