apache-zookeeper - Zookeeper 3.5 和 Curator 4.0:InterProcessMutex release() 没有删除锁路径
问题描述
我正在使用 CuratorFramework 4.0.0 和 Zookeper 3.5.4。我有这个代码片段:
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版本,锁路径不应该自动删除?我错过了什么?
谢谢!
解决方案
锁配方的“父”ZNode 被创建为容器节点。当容器节点没有剩余子节点时,它会被 ZooKeeper 清理。默认时间检查是 1 分钟,因此您不会看到父节点被删除,直到大约。1 分钟后(此值可以更改 - 有关znode.container.checkIntervalMs的详细信息,请参见此处)
推荐阅读
- c# - 将 IFormFileCollection 转换为列表
.NET 核心 - c# - 具有包含和不包含列表 C# 的元组
- c - 带有 gcc 的 makefile 返回致命错误:没有输入文件
- bash - Makefile:将警告计数存储到变量中而不使用临时文件
- python - 如何从网站下载嵌套标签中的图像
- javascript - 在 P5.js 中将周长设置为循环线的边界
- ruby-on-rails - 关于将选项传递给特征的工厂女孩语法的问题
- c++ - 我正在尝试为我的程序执行搜索功能以从我的文本文件中搜索记录
- python - Python:带有线程的 PubSub 和 WxPython 是否需要 wx.CallAfter?
- javascript - 如何停止 if 语句