Zookeeper实例ZkClient API-创建节点
2017-06-14 13:12
435 查看
import org.I0Itec.zkclient.ZkClient; /** * * @ClassName: Create_Node_Sample * @Description: TODO(使用ZkClient创建节点) * @author * @date 2017年6月14日 下午12:49:54 * */ public class Create_Node_Sample { public static void main(String[] args) throws Exception { ZkClient zkClient = new ZkClient("localhost:2181", 5000); String path = "/zk-book/c1"; zkClient.createPersistent(path, true); } }
注意:
ZkClient提供了较多的创建节点API接口,其中不同的地方是可以传递对象,和原生的Zookeeper不同。ZkClient通过createParents这个参数,ZkClient能够在内部帮助我们递归建立父节点。
扩展
参考
1.《从Paxos到Zookeeper:分布式一致性原理与实践》
2. http://javadox.com/com.101tec/zkclient/0.4/org/I0Itec/zkclient/ZkClient.html
相关文章推荐
- Zookeeper实例ZkClient API-获取节点数据内容
- Zookeeper实例ZkClient API-检查节点是否存在
- Zookeeper实例原生API--同步/异步创建节点
- Zookeeper实例Curator API-使用Curator创建节点
- Zookeeper实例原生API--异步创建节点
- Zookeeper实例原生API--同步创建节点
- Zookeeper实例ZkClient API-删除节点
- Zookeeper实例ZkClient API-更新节点内容
- Zookeeper实例ZkClient API-获取子节点列表
- Zookeeper实例Curator API-使用curator来创建一个ZooKeeper客户端
- Zookeeper实例Curator API-使用Fluent风格的API接口来创建一个ZooKeeper客户端
- Zookeeper实例原生API--同步更新节点数据
- Zookeeper实例原生API--同步获取子节点列表
- ZooKeeper之Java客户端API使用—创建节点。
- Zookeeper实例原生API--同步获取节点数据
- Zookeeper实例原生API--删除节点接口权限
- Zookeeper实例原生API--删除节点
- Zookeeper实例原生API--检查节点是否存在
- Zookeeper系列(五)Zookeeper客户端(JAVA)API之创建节点
- Zookeeper实例原生API--异步获取子节点列表