zookeeper JavaApi 查询节点

发布时间 2023-08-04 16:58:31作者: 林浅
/**
 * 1.查询数据 :get
 * 2.查询子节点 : ls
 * 3.查询节点的状态信息 :ls -s
 *
 * */
@Test
public  void  testGet1() throws Exception{
    //1.查询数据 :get
    byte[] data = client.getData().forPath("/app1");
    System.out.println(data);
}
@Test
public  void  testGet2() throws Exception{
    //2.查询子节点 : ls
    List<String> list = client.getChildren().forPath("/app4");
    System.out.println(list);
}
@Test
public  void  testGet3() throws Exception{
    //3.查询节点的状态信息 :ls -s
    Stat stat = new Stat();
    client.getData().storingStatIn(stat).forPath("/app1");
    System.out.println(stat);
}