The easiest way to fix this code is to move the Collections.sort(values) to
right after the zk.getChildren() and then use the following Comparator with
Collections.sort() and Collections.binarySearch():
/* This Comparator defines an ordering such that the strings with
* the lowest sequence
PROTECTED]
*Subject:* Re: [Zookeeper-user] Leader election
Hi Avinash, getChildren returns a list in lexicographic order, so if you
are updating the children of the election node concurrently, then you
may get a different first node with different clients. If you are using
the sequence flag
of the node name
and using the sufix value to determine order.
Hope it helps.
-Flavio
- Original Message
From: Avinash Lakshman [EMAIL PROTECTED]
To: zookeeper-user@lists.sourceforge.net
Sent: Friday, July 11, 2008 7:20:06 AM
Subject: [Zookeeper-user] Leader election
Hi
I am trying
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
: [Zookeeper-user] Leader Election
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