org.apache.solr.cloud

Class LeaderElector



  • public class LeaderElector
    extends Object
    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.