|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.solr.cloud.LeaderElector
public class LeaderElector
Leader Election process. This class contains the logic by which a
leader is chosen. First call * setup(ElectionContext)
to ensure
the election process is init'd. Next call
joinElection(ElectionContext, boolean)
to start the leader election.
The implementation follows the classic ZooKeeper recipe of creating an
ephemeral, sequential node for each candidate and then looking at the set
of such nodes - if the created node is the lowest sequential node, the
candidate that created the node is the leader. If not, the candidate puts
a watch on the next lowest node it finds, and if that node goes down,
starts the whole process over by checking if it's the lowest sequential node, etc.
Field Summary | |
---|---|
protected SolrZkClient |
zkClient
|
Constructor Summary | |
---|---|
LeaderElector(SolrZkClient zkClient)
|
Method Summary | |
---|---|
ElectionContext |
getContext()
|
static String |
getNodeName(String nStringSequence)
|
static int |
getSeq(String nStringSequence)
Returns int given String of form n_0000000001 or n_0000000003, etc. |
int |
joinElection(ElectionContext context,
boolean replacement)
Begin participating in the election process. |
protected void |
runIamLeaderProcess(ElectionContext context,
boolean weAreReplacement)
|
void |
setup(ElectionContext context)
Set up any ZooKeeper nodes needed for leader election. |
static void |
sortSeqs(List<String> seqs)
Sort n string sequence list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SolrZkClient zkClient
Constructor Detail |
---|
public LeaderElector(SolrZkClient zkClient)
Method Detail |
---|
public ElectionContext getContext()
protected void runIamLeaderProcess(ElectionContext context, boolean weAreReplacement) throws org.apache.zookeeper.KeeperException, InterruptedException, IOException
org.apache.zookeeper.KeeperException
InterruptedException
IOException
public static int getSeq(String nStringSequence)
public static String getNodeName(String nStringSequence)
public int joinElection(ElectionContext context, boolean replacement) throws org.apache.zookeeper.KeeperException, InterruptedException, IOException
org.apache.zookeeper.KeeperException
InterruptedException
IOException
public void setup(ElectionContext context) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public static void sortSeqs(List<String> seqs)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |