Class AuditorElector
- java.lang.Object
-
- org.apache.bookkeeper.replication.AuditorElector
-
@StatsDoc(name="auditor", help="Auditor related stats") public class AuditorElector extends java.lang.Object
Performing auditor election using Apache ZooKeeper. Using ZooKeeper as a coordination service, when a bookie bids for auditor, it creates an ephemeral sequential file (znode) on ZooKeeper and considered as their vote. Vote format is 'V_sequencenumber'. Election will be done by comparing the ephemeral sequential numbers and the bookie which has created the least znode will be elected as Auditor. All the other bookies will be watching on their predecessor znode according to the ephemeral sequence numbers.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Auditor
auditor
(package private) java.lang.Runnable
shutdownTask
-
Constructor Summary
Constructors Constructor Description AuditorElector(java.lang.String bookieId, ServerConfiguration conf)
AuditorElector(java.lang.String bookieId, ServerConfiguration conf, BookKeeper bkc, boolean ownBkc)
AuditorElector for performing the auditor election.AuditorElector(java.lang.String bookieId, ServerConfiguration conf, BookKeeper bkc, StatsLogger statsLogger, boolean ownBkc)
AuditorElector for performing the auditor election.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) Auditor
getAuditor()
BookieId
getCurrentAuditor()
boolean
isRunning()
If current bookie is running as auditor, return the status of the auditor.void
shutdown()
Shutting down AuditorElector.java.util.concurrent.Future<?>
start()
(package private) java.util.concurrent.Future<?>
submitElectionTask()
Performing the auditor election using the ZooKeeper ephemeral sequential znode.java.lang.String
toString()
-
-
-
Field Detail
-
auditor
Auditor auditor
-
shutdownTask
java.lang.Runnable shutdownTask
-
-
Constructor Detail
-
AuditorElector
public AuditorElector(java.lang.String bookieId, ServerConfiguration conf) throws ReplicationException.UnavailableException
-
AuditorElector
public AuditorElector(java.lang.String bookieId, ServerConfiguration conf, BookKeeper bkc, boolean ownBkc) throws ReplicationException.UnavailableException
AuditorElector for performing the auditor election.- Parameters:
bookieId
- - bookie identifier, comprises HostAddress:Portconf
- - configurationbkc
- - bookkeeper instance- Throws:
ReplicationException.UnavailableException
- throws unavailable exception while initializing the elector
-
AuditorElector
public AuditorElector(java.lang.String bookieId, ServerConfiguration conf, BookKeeper bkc, StatsLogger statsLogger, boolean ownBkc) throws ReplicationException.UnavailableException
AuditorElector for performing the auditor election.- Parameters:
bookieId
- - bookie identifier, comprises HostAddress:Portconf
- - configurationbkc
- - bookkeeper instancestatsLogger
- - stats logger- Throws:
ReplicationException.UnavailableException
- throws unavailable exception while initializing the elector
-
-
Method Detail
-
start
public java.util.concurrent.Future<?> start()
-
submitElectionTask
java.util.concurrent.Future<?> submitElectionTask()
Performing the auditor election using the ZooKeeper ephemeral sequential znode. The bookie which has created the least sequential will be elect as Auditor.
-
getAuditor
Auditor getAuditor()
-
getCurrentAuditor
public BookieId getCurrentAuditor() throws java.io.IOException, java.lang.InterruptedException
- Throws:
java.io.IOException
java.lang.InterruptedException
-
shutdown
public void shutdown() throws java.lang.InterruptedException
Shutting down AuditorElector.- Throws:
java.lang.InterruptedException
-
isRunning
public boolean isRunning()
If current bookie is running as auditor, return the status of the auditor. Otherwise return the status of elector.- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-