Zookeeper??д???????
???????????? ???????[ 2014/2/20 14:33:32 ] ??????????????? ???????
//===============================================================================
/**
* ????zookeeper server
*/
public void connect() throws Exception {
zk = new ZooKeeper(hosts?? SESSION_TIMEOUT?? new ConnWatcher());
// ??????????
connectedSignal.await();
}
/**
*
* @author Kiven
*
*/
public class ConnWatcher implements Watcher{
public void process(WatchedEvent event) {
// ????????? ???process?????? ??event.getState()?KeeperState.SyncConnected
if (event.getState() == KeeperState.SyncConnected) {
// ??????? wait??connect?????????????????
connectedSignal.countDown();
}
}
}
/**
?????????????????????:
path. znode??·??.
data. ??znode??????????.
acl. ??????????? ?????????????? ???????Ids.OPEN_ACL_UNSAFE.
???znode????. CreateMode?????????? ???????????????????.
*/
/**
* ???????????
*/
public void create(String Path?? byte[] data) throws Exception {
zk.create(Path?? data?? Ids.OPEN_ACL_UNSAFE?? CreateMode.PERSISTENT);
System.out.println("???????:"+Path);
System.out.println("=================");
}
/**
*
*?????????
*@author kiven
*@createDate 2013-01-16 15:17:22
*@param path
*@throws KeeperException
*@throws InterruptedException
*/
public void getChild(String path) throws KeeperException?? InterruptedException{
try{
List list=zk.getChildren(path?? false);
if(list.isEmpty()){
System.out.println(path+"????н??");
}else{
System.out.println(path+"?д?????");
for(String child:list){
System.out.println("??????"+child);
}
}
}catch (KeeperException.NoNodeException e) {
e.printStackTrace();
}
}
/**
* ???y??????
* @throws Exception
*/
public void setData(String path??String data) throws Exception{
zk.setData(path?? data.getBytes()?? -1);
System.out.println("set Data:"+"testSetData");
}
/**
* ??????????
* @throws Exception
*/
public void getData() throws Exception{
System.out.println("get Data:");
zk.getData(nodePath?? false?? null);
}
/**
* ??????
* @param path
* @throws Exception
*/
public void delete(String path) throws Exception{
System.out.println("??????:"+path);
//????汾????znode??汾?????£?????????????????????????????????汾???????-1??????????汾??????????
zk.delete(path?? -1);
}
/**
* ???????
*/
public void close() {
try {
zk.close();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??????????????????????????????????APP?????????????????????????????????????????SQL??????????????Щ????????????????????????????????????????????????????????????????????????Web????????????????????????????????????????????????????漰????????????????????????????????Java???????????Щ??????????????????????????????????????????????????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????