Apache Curator :让ZooKeeper使用更容易
Apache Curator -是按照Eric Evans和Martin Fowler提出的Fluent Style流畅风格,让ZooKeeper使用得更容易。
这是NetFlix释放的又一个开源项目。
获得一个ZooKeeper连接只需要下面代码:
CuratorFrameworkFactory.newClient(zookeeperConnectionString, retryPolicy)
如果规定重连次数,代码如下
|
客户端就连接到ZooKeeper了,无需再显式关闭。
通过下面代码直接调用ZooKeeper:
client.create().forPath("/my/path", myData)
Curator的好处是它来管理ZooKeeper连接,如果连接有问题将会重新进行连接。