Package org.apache.bookkeeper.client
Class RoundRobinDistributionSchedule
- java.lang.Object
-
- org.apache.bookkeeper.client.RoundRobinDistributionSchedule
-
- All Implemented Interfaces:
DistributionSchedule
public class RoundRobinDistributionSchedule extends java.lang.Object implements DistributionSchedule
A specificDistributionSchedulethat 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
Constructors Constructor Description RoundRobinDistributionSchedule(int writeQuorumSize, int ackQuorumSize, int ensembleSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DistributionSchedule.AckSetgetAckSet()Returns an ackset object, responses should be checked against this.DistributionSchedule.QuorumCoverageSetgetCoverageSet()DistributionSchedule.AckSetgetEnsembleAckSet()Returns an ackset object useful to wait for all bookies in the ensemble, responses should be checked against this.DistributionSchedule.WriteSetgetEnsembleSet(long entryId)Return the set of bookies indices to send the messages to the whole ensemble.java.util.BitSetgetEntriesStripedToTheBookie(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.intgetWriteQuorumSize()DistributionSchedule.WriteSetgetWriteSet(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(java.lang.Integer... values)
-
-
-
Method Detail
-
getWriteSet
public DistributionSchedule.WriteSet getWriteSet(long entryId)
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
public DistributionSchedule.WriteSet getEnsembleSet(long entryId)
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
static DistributionSchedule.WriteSet writeSetFromValues(java.lang.Integer... values)
-
getAckSet
public DistributionSchedule.AckSet getAckSet()
Description copied from interface:DistributionScheduleReturns an ackset object, responses should be checked against this.- Specified by:
getAckSetin interfaceDistributionSchedule
-
getEnsembleAckSet
public DistributionSchedule.AckSet 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
public DistributionSchedule.QuorumCoverageSet 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
public java.util.BitSet getEntriesStripedToTheBookie(int bookieIndex, long startEntryId, long lastEntryId)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
-
-