Package org.apache.bookkeeper.client
Class RoundRobinDistributionSchedule
java.lang.Object
org.apache.bookkeeper.client.RoundRobinDistributionSchedule
- All Implemented Interfaces:
DistributionSchedule
A specific
DistributionSchedule that places entries in round-robin
fashion. For ensemble size 3, and quorum size 2, Entry 0 goes to bookie 0 and
1, entry 1 goes to bookie 1 and 2, and entry 2 goes to bookie 2 and 0, and so
on.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.bookkeeper.client.DistributionSchedule
DistributionSchedule.AckSet, DistributionSchedule.QuorumCoverageSet, DistributionSchedule.WriteSet -
Field Summary
Fields inherited from interface org.apache.bookkeeper.client.DistributionSchedule
NULL_WRITE_SET -
Constructor Summary
ConstructorsConstructorDescriptionRoundRobinDistributionSchedule(int writeQuorumSize, int ackQuorumSize, int ensembleSize) -
Method Summary
Modifier and TypeMethodDescriptionReturns an ackset object, responses should be checked against this.Returns an ackset object useful to wait for all bookies in the ensemble, responses should be checked against this.getEnsembleSet(long entryId) Return the set of bookies indices to send the messages to the whole ensemble.getEntriesStripedToTheBookie(int bookieIndex, long startEntryId, long lastEntryId) Get the bitset representing the entries from entry 'startEntryId' to 'lastEntryId', that would be striped to the bookie with index - bookieIndex.intgetWriteSet(long entryId) Return the set of bookie indices to send the message to.intgetWriteSetBookieIndex(long entryId, int writeSetIndex) Return the WriteSet bookie index for a given and index in the WriteSet.booleanhasEntry(long entryId, int bookieIndex) Whether entry presents on given bookie index.(package private) static DistributionSchedule.WriteSetwriteSetFromValues(Integer... values)
-
Constructor Details
-
RoundRobinDistributionSchedule
public RoundRobinDistributionSchedule(int writeQuorumSize, int ackQuorumSize, int ensembleSize)
-
-
Method Details
-
getWriteSet
Description copied from interface:DistributionScheduleReturn the set of bookie indices to send the message to.- Specified by:
getWriteSetin interfaceDistributionSchedule
-
getWriteSetBookieIndex
public int getWriteSetBookieIndex(long entryId, int writeSetIndex) Description copied from interface:DistributionScheduleReturn the WriteSet bookie index for a given and index in the WriteSet.- Specified by:
getWriteSetBookieIndexin interfaceDistributionSchedule- Returns:
-
getEnsembleSet
Description copied from interface:DistributionScheduleReturn the set of bookies indices to send the messages to the whole ensemble.- Specified by:
getEnsembleSetin interfaceDistributionSchedule- Parameters:
entryId- entry id used to calculate the ensemble.- Returns:
- the set of bookies indices to send the request.
-
writeSetFromValues
-
getAckSet
Description copied from interface:DistributionScheduleReturns an ackset object, responses should be checked against this.- Specified by:
getAckSetin interfaceDistributionSchedule
-
getEnsembleAckSet
Description copied from interface:DistributionScheduleReturns an ackset object useful to wait for all bookies in the ensemble, responses should be checked against this.- Specified by:
getEnsembleAckSetin interfaceDistributionSchedule
-
getCoverageSet
- Specified by:
getCoverageSetin interfaceDistributionSchedule
-
hasEntry
public boolean hasEntry(long entryId, int bookieIndex) Description copied from interface:DistributionScheduleWhether entry presents on given bookie index.- Specified by:
hasEntryin interfaceDistributionSchedule- Parameters:
entryId- - entryId to check the presence on given bookie indexbookieIndex- - bookie index on which it need to check the possible presence of the entry- Returns:
- true if it has entry otherwise false.
-
getEntriesStripedToTheBookie
Description copied from interface:DistributionScheduleGet the bitset representing the entries from entry 'startEntryId' to 'lastEntryId', that would be striped to the bookie with index - bookieIndex. Value of the bit with the 'bitIndex+n', indicate whether entry with entryid 'startEntryId+n' is striped to this bookie or not.- Specified by:
getEntriesStripedToTheBookiein interfaceDistributionSchedule- Parameters:
bookieIndex- index of the bookie in the ensemble starting with 0startEntryId- starting entryidlastEntryId- last entryid- Returns:
- the bitset representing the entries that would be striped to the bookie
-
getWriteQuorumSize
public int getWriteQuorumSize()- Specified by:
getWriteQuorumSizein interfaceDistributionSchedule
-