org.apache.zookeeper.server.quorum
Class LeaderElection

java.lang.Object
  extended by org.apache.zookeeper.server.quorum.LeaderElection
All Implemented Interfaces:
Election

public class LeaderElection
extends java.lang.Object
implements Election


Nested Class Summary
static class LeaderElection.ElectionResult
           
 
Field Summary
protected static java.util.Random epochGen
           
protected  QuorumPeer self
           
 
Constructor Summary
LeaderElection(QuorumPeer self)
           
 
Method Summary
protected  LeaderElection.ElectionResult countVotes(java.util.HashMap<java.net.InetSocketAddress,Vote> votes, java.util.HashSet<java.lang.Long> heardFrom)
           
 Vote lookForLeader()
          Invoked in QuorumPeer to find or elect a new leader.
 void shutdown()
          There is nothing to shutdown in this implementation of leader election, so we simply have an empty method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

epochGen

protected static java.util.Random epochGen

self

protected QuorumPeer self
Constructor Detail

LeaderElection

public LeaderElection(QuorumPeer self)
Method Detail

countVotes

protected LeaderElection.ElectionResult countVotes(java.util.HashMap<java.net.InetSocketAddress,Vote> votes,
                                                   java.util.HashSet<java.lang.Long> heardFrom)

shutdown

public void shutdown()
There is nothing to shutdown in this implementation of leader election, so we simply have an empty method.

Specified by:
shutdown in interface Election

lookForLeader

public Vote lookForLeader()
                   throws java.lang.InterruptedException
Invoked in QuorumPeer to find or elect a new leader.

Specified by:
lookForLeader in interface Election
Throws:
java.lang.InterruptedException


Copyright © 2010 The Apache Software Foundation