The other thread was already quite big and covering a large range of
issues so thought I'd spin up a little separate thread :)

I've just updated the patch to include better javadoc which is linked
to an embedded HTML documentation describing the protocol. The
documention includes the pseudocode from the online ZooKeeper
presentation (that I used) and I've also included the text from
ZOOKEEPER-79 which I'm glad to say seems to match up perfectly with
the pseudocode I'd used :)

One thing confused me though; the last paragraph says...

This protocol guarantees that there is at any time only one node that
thinks it is the leader. But it does not disseminate information about
who is the leader. If you want everyone to know who is the leader, you
can have an additional Znode whose value is the name of the current
leader (or some identifying information on how to contact the leader,
etc.). Note that this cannot be done atomically, so by the time other
nodes find out who the leader is, the leadership may already have
passed on to a different node.

In the current implementation, WriteLock - each znode can know,
whenever it attempts to acquire the lock - if it didn't get the lock,
who the owner is. I guess this is only true momentarily the split
second that the acquire() method is called (i.e. the exact moment the
getChildren() is called and the lowest value is found). Or is there
some other subtle issue I'm not seeing?

I guess we could add a method to WriteLock - if folks wanted - a kinda
queryLeader() method where we just use the same algorithm to find who
the current leader is - if folks cared. Though am not sure how useful
knowing who the leader is :). Though I guess writing the leader's
identity to some canonical znode that any other znode can read
whenever it wishes is less risky and maybe simpler.


Open Source Integration

Reply via email to