【问题标题】:Zookeeper 3.5 and Curator 4.0: InterProcessMutex release() didn't delete lock pathZookeeper 3.5 和 Curator 4.0:InterProcessMutex release() 没有删除锁路径
【发布时间】:2018-09-21 12:28:54
【问题描述】:

我正在使用 CuratorFramework 4.0.0 和 Zookeper 3.5.4。 我有这个代码sn-p:

RetryPolicy retryPolicy = new RetryOneTime(1000);
client = CuratorFrameworkFactory.newClient(zkConnectionString, retryPolicy);
client.start();
String path = "/node/test_lock";
client.createContainers(path);
InterProcessSemaphoreMutex lock = new InterProcessSemaphoreMutex(client, path);
if (lock.acquire(3, TimeUnit.MILLISECONDS)) {                 
    LOGGER.debug(client.exists(lockPath) == null);
}
if (lock != null){
    lock.release();  // After I call this method,
                     // the "/node/test_lock" node still exists.
}

使用zookeeper 3.5版本,锁路径不应该自动删除?我错过了什么?

谢谢!

【问题讨论】:

    标签: apache-zookeeper apache-curator


    【解决方案1】:

    锁配方的“父”ZNode 创建为Container nodes。当容器节点没有剩余子节点时,它会被 ZooKeeper 清理。默认时间检查是 1 分钟,因此您不会看到父节点被删除,直到大约。 1 分钟后(此值可以更改 -- 有关znode.container.checkIntervalMs 的详细信息,请参阅此处)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多