4.3 创建子节点

@Test
public void createNode() throws KeeperException, InterruptedException {
    /*
    参数1: 节点名  比如: "/atguigu"
    参数2: 节点存储的数据. 字节数组
    参数3: 节点的acl
    参数4: 节点的类型  永久/暂时/带序列号的...
    返回值: 创建的节点的实际路径
     */
    String createdNode = zkClient.create(
            "/atguigu",
            "hello world...".getBytes(),
            ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    System.out.println(createdNode);

}
Copyright © 尚硅谷大数据 & 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-11-08 08:23:33

results matching ""

    No results matching ""