将多个Curator连接到单个Zookeeper实例?

时间:2016-07-10 16:25:46

标签: java apache-zookeeper apache-curator

是否可以将多个策展人连接到同一个Zookeeper实例?如果是这样的话?

似乎Zookeeper只有一个客户端端口。

出现这种需求,因为在测试期间我需要将一些初始化数据写入Zookeeper,但目前我已经将主要的curator实例(我无权访问)连接到Zookeeper。

2 个答案:

答案 0 :(得分:2)

我不确定您为什么担心单个客户端端口。只需根据需要分配尽可能多的Curator实例。但是,为什么你想要超过1个Curator实例?单个Curator实例可用于应用程序中的所有ZooKeeper交互。您可以将其视为JDBC连接。

答案 1 :(得分:0)

As Zookeeper is intended to be used by different process on different machines. By definition you will have many clients connected to the same Zookeeper, If you choose those clients to be the Curator implementation (which I recommend) then you will have different curators connected to the same ZK.

Whether those different instances are in the same process or not is irrelevant, but as Rangalt pointed out, there is no use for more than one instance per process.