基于zookeeper3.6.3 的java client
maven pom 添加依赖
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.3</version>
</dependency>
java client demo
import org.apache.zookeeper.*;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class ZkClient {
private static CountDownLatch connectedSemaphore = new CountDownLatch(1);
private static String connectString
= "192.168.130.129:2181," +
"192.168.130.130:2181," +
"192.168.130.131:2181";