So having recently discovered ZooKeeper, I'm really liking it - good job folks!
I've seen discussions of building high level features from the core ZK library and had not seen any available on the interweb so figured I'd have a try creating a simple one. Feel free to ignore it if a ZK ninja can think of a neater way of doing it - I've basically followed the protocol defined in the recent ZK presentation... http://developer.yahoo.com/blogs/hadoop/2008/03/intro-to-zookeeper-video.html I've submitted the code as a patch here... https://issues.apache.org/jira/browse/ZOOKEEPER-78 I figured the Java Client might as well come with some helper code to make doing things like exclusive locks or leader elections easier; we could always spin them out into a separate library if and when required etc. Right now its one fairly simple class :) Currently its a simple class where you can register a Runnable to be invoked when you have the lock; or you can just keep asking if you have the lock now and again as you see fit etc. WriteLock locker = new WriteLock(zookeeper, "/foo/bar"); locker.setWhenOwner(new Runnable() {...}); // fire this code when owner... // lets try own it locker.acquire(); // I may or may not have the lock now if (locker.isOwner()) {....} // time passes locker.close(); Thoughts? -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com