Apache Curator使用重试逻辑创建

时间:2017-05-24 12:27:45

标签: apache-zookeeper apache-curator

我想知道Apache Curator中的create()方法是否使用重试逻辑包装原始Zookeeper create方法?

我已经编写了一些创建ZNode的代码,我希望默认情况下它会重试。如果不是,那么用重试功能编写create函数的最佳方法是什么?

CuratorFramework client = CuratorFrameworkFactory.newClient("0.0.0.0:32770", new RetryUntilElapsed(3000, 1000));
client.start();

try {
     //make sure you're connected to zookeeper.
    client.blockUntilConnected();

     //Make sure the parants are created.
    client.create().creatingParentsIfNeeded().forPath("/larry-smells/foop", "tuna?".getBytes());
} catch (Exception e) {
    System.out.println(e.toString());
}

1 个答案:

答案 0 :(得分:2)

Apache Curator中的所有操作都使用重试策略。所以,是的,create()使用重试策略。注意:我是策展人的主要作者。