Google's Chubby distributed lock manager has a feature called "sequencers" that I would like to emulate using ZooKeeper. Is there a known good way to do so?
A sequencer works as follows:
The goal is to prevent a situation where a client dies after making a call to a remote service which must be protected by a lock.
The main paper on Chubby is available at http://research.google.com/archive/chubby.html. Sequencers are discussed in section 2.4.
Thanks!
The zookeeper lock recipes all involve the locking process create a sequential ephemeral znode. The name of the sequential ephemeral znode will be unique, and the znode will cease to exist if the lockers session expires due to the locker not sending a valid heartbeat within the timeout.
So the locking process just needs to pass the name of the sequential ephemeral znode it created while locking to the remote service, and the remote service can check the existence of the znode before processing.
You can be even have the remote service add a watch to the znode, and be notified when the znode is removed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With