/**
* @author Keeny (2013-12-31)
**/
public class Test {
public static void main(String[] args) throws IOException, KeeperException, InterruptedException, NoSuchAlgorithmException {
ZooKeeper zk = new ZooKeeper("192.168.192.142:2181", 500000, new Watcher() {
// 监控所有被触发的事件
public void process(WatchedEvent event) {
System.out.println("WatchedEvent=" + event.toString());
// dosomething
}
});
// 创建一个节点root,数据是mydata,不进行ACL权限控制,节点为永久性的(即客户端shutdown了也不会消失)
List<ACL> acls = new ArrayList<ACL>(2);
Id id1 = new Id("digest", DigestAuthenticationProvider.generateDigest("admin:admin123"));
ACL acl1 = new ACL(ZooDefs.Perms.ALL, id1);
Id id2 = new Id("digest", DigestAuthenticationProvider.generateDigest("guest:guest123"));
ACL acl2 = new ACL(ZooDefs.Perms.READ, id2);