curator使用指南

1.連接zookeeper服務端

CuratorFramework zkClient = CuratorFrameworkFactory.newClient(hostPort,new RetryNTimes(10,1000));
  1. 刪除節點
 String res = zkClient.delete().forPath("/temp")

刪除成功返回null 刪除失敗拋異常
3.創建節點

String haveNo = zkClient.create()
										.creatingParentsIfNeeded()
										.forPath("/pp/ppp/ppppp","ppp".getBytes());

創建成功返回成功的路徑,創建失敗拋出異常

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章