zookeeper 故障重连机制
一、连接多个服务器,用逗号隔开
- 如果在连接时候zk服务器宕机
- To create a client session the application code must provide a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server (e.g.
- "127.0.0.1:4545" or "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"). The ZooKeeper client library will pick an arbitrary server and try to connect to it. If this connection fails, or if the client
- becomes disconnected from the server for any reason, the client will automatically try the next server in the list, until a connection is (re-)established.
- 创建一个client session 应用代码必须提供一个连接字符串包含一个逗号分隔的主机:端口 列表,
- 每个对应到一个ZooKeeper server (e.g.
- "127.0.0.1:4545" or "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002").
- ZooKeeper 客户端库 会选择一个任意的server 和尝试连接到它。
- 如果这个连接失败,或者 如果客户端变的不能连接,客户端会自动 尝试下一个server 在列表里,知道一个连接重新创建。
- 如果已经连接之后服务器宕机
- SessionMovedException. There is an internal exception that is generally not seen by clients called the SessionMovedException. This exception occurs because a request was received on a connection
- for a session which has been reestablished on a different server. The normal cause of this error is a client that sends a request to a server, but the network packet gets delayed, so the client
- times out and connects to a new server. When the delayed packet arrives at the first server, the old server detects that the session has moved, and closes the client connection. Clients normally do
- not see this error since they do not read from those old connections. (Old connections are usually closed.) One situation in which this condition can be seen is when two clients try to reestablish
- the same connection using a saved session id and password. One of the clients will reestablish the connection and the second client will be disconnected (causing the pair to attempt to re-establish
- its connection/session indefinitely).
- SessionMovedException. 有一个内部的异常,那是通常不被客户端请求SessionMovedException 看到。
- 这个exception 因为 一个请求被接收在一个连接对于一个会话 精被重新建立到一个不同的zk server.
- 这个错误的通常情况是一个客户端发送一个请求到一个服务器,
- 但是网络包延时了,因此客户端超时 ,连接到一个新的服务器.当延迟的packet 到达第一个server,
- old server 检测倒 session 已经移动了,关闭客户端连接。
- 客户端通常不会看到这个错误 因为它们不会从老的连接读取(老的连接通常是被关闭的)
- 一种情况是这个状况可以被看到当 2个客户端尝试重建建立相同的连接使用一个保存的会话id和密码。
参考链接:http://blog.csdn.net/zhaoyangjian724/article/details/52218172
zookeeper 故障重连机制的更多相关文章
- zk 节点故障 重连机制
<pre name="code" class="html">如果在连接时候zk服务器宕机 To create a client session th ...
- Zookeeper 重连机制
Zookeeper 重连机制 public class ZKConnectSessionWatcher implements Watcher { public final static String ...
- ActiveMQ的断线重连机制
断线重连机制是ActiveMQ的高可用性具体体现之一.ActiveMQ提供failover机制去实现断线重连的高可用性,可以使得连接断开之后,不断的重试连接到一个或多个brokerURL. 默认情况下 ...
- 正确理解IM长连接的心跳及重连机制,并动手实现(有完整IM源码)
1.引言 说道“心跳”这个词大家都不陌生,当然不是指男女之间的心跳,而是和长连接相关的.顾名思义就是证明是否还活着的依据. 什么场景下需要心跳呢?目前我们接触到的大多是一些基于长连接的应用需要心跳来“ ...
- 详细解析kafka之 kafka消费者组与重平衡机制
消费组组(Consumer group)可以说是kafka很有亮点的一个设计.传统的消息引擎处理模型主要有两种,队列模型,和发布-订阅模型. 队列模型:早期消息处理引擎就是按照队列模型设计的,所谓队列 ...
- Dubbo超时和重连机制
dubbo启动时默认有重试机制和超时机制.超时机制的规则是如果在一定的时间内,provider没有返回,则认为本次调用失败,重试机制在出现调用失败时,会再次调用.如果在配置的调用次数内都失败,则认为此 ...
- testng增加失败重跑机制
注: 以下内容引自 http://www.yeetrack.com/?p=1015 testng增加失败重跑机制 Posted on 2014 年 10 月 31 日 使用Testng框架搭建自动测试 ...
- Netty 之 Netty生产级的心跳和重连机制
https://blog.csdn.net/z69183787/article/details/52625095 最近工作比较忙,但闲暇之余还是看了阿里的冯家春(fengjiachun)的github ...
- 基于netty实现的长连接,心跳机制及重连机制
技术:maven3.0.5 + netty4.1.33 + jdk1.8 概述 Netty是由JBOSS提供的一个java开源框架.Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速 ...
随机推荐
- Java Timer定时器时,每次重复执行了两次任务的解决方案
web.xml监听配置 com.numenzq.mc.service.impl.TimerListener TimerListener类 public class TimerListener impl ...
- 个人训练记录-赛码"bestcoder"杯中国大学生程序设计冠军赛
A.Movie 题意是给n个线段,要求求出是否存在三个不相交的线段,是的话输出yes,否则输出no.根据贪心的想法,可以先找出右端点r'最小的线段,他是三条线段中最左的那条,再找出左端点l'最大的线段 ...
- Java Web开发中MVC设计模式简介
一.有关Java Web与MVC设计模式 学习过基本Java Web开发的人都已经了解了如何编写基本的Servlet,如何编写jsp及如何更新浏览器中显示的内容.但是我们之前自己编写的应用一般存在无条 ...
- javascript的escape()方法
escape() 方法:采用ISO Latin字符集对指定的字符串进行编码.所有的空格符.标点符号.特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编码 ...
- EditPlus 3.7.164 中文版(4月3日更新)
新的版本汉化了之前无法汉化的部分内容,并修复了旧汉化版的部分问题. 欢迎下载新的翻译文件.
- curl 模拟请求get/post
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx24a0ef ...
- CF 484E - Sign on Fence
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...
- Shellcode编程小技巧
工作需要,需要注入其他程序监控一些东西,检测到的数据通过WM_COPY 消息发送给显示窗体.(大体是这样的还没定稿) ##1 选择一个框架 ## tombkeeper/Shellcode_Templa ...
- 在Ubuntu Server下配置LAMP环境
1. 下载Ubuntu Server,地址https://www.ubuntu.com/download/server 2. 在虚拟机上安装Ubuntu Server.根据安装引导过程一步步安装,跟在 ...
- MVC 缓存
MVC 缓存 http://blog.zhaojie.me/2009/09/aspnet-mvc-fragment-cache-1.html redis http://www.cnblogs.com ...