ZooKeeper客户端地址列表的随机原理
来源:互联网 发布:前端程序员简历模板 编辑:程序博客网 时间:2024/05/28 16:04
查看PDF版本 转自:@ni掌柜nileader@gmail.com http://nileader.blog.51cto.com/1381108/932948
在之前一个文章《ZooKeeper Java API 使用样例》中提到,客户端使用ZooKeeper的时候,首先会建立与ZooKeeper的连接,方法是通过调用下面这个构造方法来实现的。
- public ZooKeeper(String connectString, //
- int sessionTimeout, //
- Watcher watcher,//
- boolean canBeReadOnly )
- throws IOException
- 192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181
- new ZooKeeper(“192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181”,...)
- ConnectStringParser connectStringParser =
new ConnectStringParser(“192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181”);
- public final class ConnectStringParser {
- private final String chrootPath;
- private final ArrayList<InetSocketAddress> serverAddresses = new ArrayList<InetSocketAddress>();
- }
- public StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
- throws UnknownHostException {
- ……
- ……
- Collections.shuffle(this.serverAddresses);
- }
- public InetSocketAddress next(long spinDelay) {
- ++currentIndex;
- if (currentIndex == serverAddresses.size()) {
- currentIndex = 0;
- }
- ……
- ……
- return serverAddresses.get(currentIndex);
- }
0 0
- ZooKeeper客户端地址列表的随机原理
- ZooKeeper客户端地址列表的随机原理
- ZooKeeper客户端地址列表的随机原理
- ZooKeeper客户端地址列表的随机原理
- 【ZooKeeper Notes 11】ZooKeeper客户端地址列表的随机原理
- 【ZooKeeper Notes 11】ZooKeeper客户端地址列表的随机原理
- 【ZooKeeper Notes 11】ZooKeeper客户端地址列表的随机原理
- zookeeper 客户端的实现
- zookeeper的python客户端
- Zookeeper的Java客户端
- ZooKeeper 客户端的使用
- zookeeper的java客户端
- Zookeeper客户端的使用
- 【ZooKeeper Notes 29】 修复“ZooKeeper客户端打印当前连接的服务器地址为null”的Bug问题描述
- zookeeper角色分配原理和命令行客户端
- Zookeeper的原理介绍
- Zookeeper 的工作原理
- ZooKeeper的工作原理
- 链表实现多项式加法和乘法
- Lua内存泄漏应对方法
- 《编程之美》蚂蚁爬杆问题的扩展
- OC学习笔记-NSRange、Point、Size、Rect
- spring下tomcat不能启动问题
- ZooKeeper客户端地址列表的随机原理
- string类、字符串数组相关问题
- 《数据结构》课程设计 字符串加密应用
- BT协议分析
- nyoj 1057 寻找最大数(三)
- unity__回顾GUI
- HDU 1010 Tempter of the Bone
- 在C中如何使函数返回数组
- Sicily 2499 平方数