使用zkClient连接zookeeper服务
来源:互联网 发布:二手备案域名 万网 编辑:程序博客网 时间:2024/06/05 17:32
直接上代码:
package com.sdp.zookeeper;import java.util.List;import org.I0Itec.zkclient.ZkClient;import org.apache.zookeeper.CreateMode;public class Main {public static void main(String[] args) {ZkClient zkClient = new ZkClient("127.0.0.1:2181");//建立连接// zkClient.exists('/root'); //判断目录是否存在zkClient.create("/root","mydata", CreateMode.PERSISTENT);//创建目录并写入数据String data=zkClient.readData("/root");System.out.println(data);zkClient.delete("/root");//删除目录// zkClient.deleteRecursive("/root");//递归删除节目录}}
别忘记引入zkClient的jar包。以gradle为例:
dependencies { compile group: 'com.101tec', name: 'zkclient', version: '0.9'}
0 0
- 使用zkClient连接zookeeper服务
- ZooKeeper之zkClient使用
- zookeeper zkClient使用
- 项目使用dubbo 、zookeeper服务报 Could not initialize class org.I0Itec.zkclient.ZkClient
- zookeeper三:zkClient的使用
- Zookeeper学习(五):ZKClient的使用
- zookeeper学习笔记-zkclient,curator使用
- zookeeper学习笔记-zkclient,curator使用
- ZooKeeper学习笔记-6---ZkClient使用
- Zookeeper学习(五):ZKClient的使用
- zookeeper学习笔记-zkclient,curator使用
- Zookeeper学习(五):ZKClient的使用
- zookeeper的zkclient的使用简介
- Zookeeper——3、使用zkClient操作zookeeper
- I0Itec-zkClient --- Kafka中使用的Zookeeper客户端
- 使用zkclient操作zookeeper的学习过程记录
- Zookeeper客户端库ZkClient
- Zookeeper API 和 Zkclient
- Understanding Convolutional Neural Networks for NLP(理解NLP中的卷积神经网络) 阅读笔记
- android 跑马灯
- CodeForces 347A Difference Row
- ListView实现下拉刷新(第一次打开listView的界面进行自动刷新)和上拉加载更多
- 前缀转后缀程序源代码(pascal)
- 使用zkClient连接zookeeper服务
- Javascript 基础之Array对象
- 7.jvm之认证和签名
- Android Design Support Library初探,NavigationView实践
- 动态加载JDBC Jar包连接数据库
- 谈谈MVC模式
- 【Heritrix 02】Heritrix包介绍
- 1077. Kuchiguse (20)
- javascript获取dom的下一个节点方法