标签:
创建持久节点和临时节点
ZooKeeper zk=new ZooKeeper(HOST,CLIENT_SESSION_TIMEOUT,new Watcher(){ @Override public void process(WatchedEvent event) { logger.info("---watcher--eventtype=="+event.getType()); } }); //创建持久节点 if(zk.exists(LEADER_PATH,false)==null){ zk.create(LEADER_PATH, null,Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } //创建临时节点 path=zk.create(LEADER_PATH+"/lock-", null,Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
标签:
原文地址:http://www.cnblogs.com/davidwang456/p/5127412.html