Good point. The recipe we show guarantees there will be a single leader 
elected, but only the leader knows it. Jacob Levy has been implementing a 
client library to do leader election, so he should really chime in here, but 
just in case he doesn't: I believe Jacob's solution was for the leader to 
create an ephemeral znode called LEADER with its id as the data when it 
becomes the leader, and then delete the node before relinquishing leadership. 
The other nodes then watch for the existence of the LEADER znode to see 
leadership changes.

ben

On Tuesday 17 June 2008 09:28:39 Avinash Lakshman wrote:
> Hi All
>
> I am trying to write a simple leader election module and I have 5 nodes A,
> B, C, D and E amongst which I need to elect a leader. Now I am following
> the example using SEQUENCE flags and trying to use the technique where the
> herd effect can be done away with. So I have A create a znode L-1, B create
> znode L-2 .... and E create znode L-5. After this I have L-2 watch L-1, L-3
> watch L-2 etc. Let us assume A was elected leader. When A dies B should
> automatically become the leader and this seems to be working. What I need
> to know is how to C, D and E know about this? Do I need another mechanism
> to disseminate this information? I ask because not all znodes are being
> watched i.e C, D and E are not watching for L-1 which is the znode created
> by A. So how will they learn as to who the new leader is since no watch
> event will be triggered at their end.
>
> Thanks in advance
> Avinash



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Zookeeper-user mailing list
Zookeeper-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/zookeeper-user

Reply via email to