Apache Zookeeper/Curator的锁定生存时间 [英] Apache Zookeeper / Curator time-to-live on locks

查看:470
本文介绍了Apache Zookeeper/Curator的锁定生存时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Curator锁配方(或较低级的ZooKeeper)中是否有用于自动释放超过TTL的锁的功能?如果没有,是否有解决该问题的最佳实践?我看到Curator在客户端连接丢失的情况下会自动释放锁,这很好...而且锁获取超时也很有帮助.

Is there any facility in the Apache Curator lock recipes (or lower-level ZooKeeper) for auto-releasing locks that have exceeded some TTL? If not, is there a best practice for dealing with that? I see that Curator automatically releases locks in the case of the client connection being lost, which is nice...and the timeout on lock acquisition is also helpful.

我想知道我需要通过执行一个周期性工作来寻找保护锁的程度,该工作寻找已经存在很长时间的锁并手动释放它们.我会通过让我自己的进程直接删除相关的ZNode来做到这一点吗?

I'm wondering to what degree I need to protect my system by making a recurring job that looks for locks that have been around to long and manually releasing them. Would I do that by having my separate process directly delete the relevant ZNode?

推荐答案

计算器的锁是使用EPHEMERAL znodes实现的.因此,如果锁持有人以某种方式变得不稳定,ZooKeeper应该自动释放锁.如果您正在寻找一种方法来撤消其他进程持有的锁,则一些Curator的锁配方具有合作的撤消功能.除此之外,从进程下面删除锁似乎会导致极大的不稳定.我想不出这样做的充分理由.

Curator's locks are implemented using EPHEMERAL znodes. So, if the lock holder becomes unstable in some way, ZooKeeper should automatically release the lock. If you're looking for a way to revoke locks held by other processes, some of Curator's lock recipes have a cooperative revoking facility. Other than that, deleting a lock from underneath a process seems like it would cause tremendous instability. I can't think of a good reason to do it.

(注意:我是策展人的主要作者)

(note: I'm the main author of Curator)

这篇关于Apache Zookeeper/Curator的锁定生存时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆