<dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.7.0</version> </dependency> import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; public class ZooKeeperExample { public static void main(String[] args) throws Exception { ZooKeeper zooKeeper = new ZooKeeper(connectString, sessionTimeout, new Watcher() { public void process(WatchedEvent event) { } }); } } String path = "/example/node"; byte[] data = "Hello, ZooKeeper!".getBytes(); ZooKeeper createNode(String path, byte[] data, List<ACL> acl, CreateMode createMode) throws KeeperException, InterruptedException; byte[] getData(String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException; void setData(String path, byte[] data, int version) throws KeeperException, InterruptedException; void delete(String path, int version) throws InterruptedException, KeeperException; void close() throws InterruptedException;


上一篇:
下一篇:
切换中文