【问题标题】:Apache Curator create with retry logic使用重试逻辑创建 Apache Curator
【发布时间】:2017-05-24 20:48:06
【问题描述】:

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

我编写了一些创建 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());
}

【问题讨论】:

  • 不需要调用client.blockUntilConnected()。仅供参考

标签: apache-zookeeper apache-curator


【解决方案1】:

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

【讨论】:

  • 这里的默认重试策略是什么?
  • RetryUntilElapsed - 构建 CuratorFramework 实例时使用的任何内容
猜你喜欢
  • 1970-01-01
  • 2020-08-06
  • 1970-01-01
  • 2017-03-21
  • 1970-01-01
  • 1970-01-01
  • 2021-12-15
  • 2019-05-25
  • 2017-10-08
相关资源
最近更新 更多