4.4 获取子节点并监听

@Test
public void getChildren() throws KeeperException, InterruptedException {
    /*
    获取子节点
    参数1: 获取的是参数1的子节点
    参数2: 是否监听子节点的变化
    返回值: 所有的子节点
     */
    List<String> children = zkClient.getChildren("/", true);
    for (String child : children) {
        System.out.println(child);
    }
    // 为了防止进程结束, 加入延时
    Thread.sleep(Long.MAX_VALUE);
}
Copyright © 尚硅谷大数据 & 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-11-08 08:23:33

results matching ""

    No results matching ""