Class AuditorElector
java.lang.Object
org.apache.bookkeeper.replication.AuditorElector
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 -
Constructor Summary
ConstructorsConstructorDescriptionAuditorElector(String bookieId, ServerConfiguration conf) AuditorElector(String bookieId, ServerConfiguration conf, BookKeeper bkc, boolean ownBkc) AuditorElector for performing the auditor election.AuditorElector(String bookieId, ServerConfiguration conf, BookKeeper bkc, StatsLogger statsLogger, boolean ownBkc) AuditorElector for performing the auditor election. -
Method Summary
Modifier and TypeMethodDescription(package private) AuditorbooleanIf current bookie is running as auditor, return the status of the auditor.voidshutdown()Shutting down AuditorElector.Future<?>start()(package private) Future<?>Performing the auditor election using the ZooKeeper ephemeral sequential znode.toString()
-
Field Details
-
Constructor Details
-
AuditorElector
public AuditorElector(String bookieId, ServerConfiguration conf) throws ReplicationException.UnavailableException -
AuditorElector
public AuditorElector(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(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 Details
-
start
-
submitElectionTask
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
- Throws:
IOExceptionInterruptedException
-
shutdown
Shutting down AuditorElector.- Throws:
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
-