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 specificDistributionSchedule
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
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.AckSet
getAckSet()
Returns an ackset object, responses should be checked against this.DistributionSchedule.QuorumCoverageSet
getCoverageSet()
DistributionSchedule.AckSet
getEnsembleAckSet()
Returns an ackset object useful to wait for all bookies in the ensemble, responses should be checked against this.DistributionSchedule.WriteSet
getEnsembleSet(long entryId)
Return the set of bookies indices to send the messages to the whole ensemble.java.util.BitSet
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.int
getWriteQuorumSize()
DistributionSchedule.WriteSet
getWriteSet(long entryId)
Return the set of bookie indices to send the message to.int
getWriteSetBookieIndex(long entryId, int writeSetIndex)
Return the WriteSet bookie index for a given and index in the WriteSet.boolean
hasEntry(long entryId, int bookieIndex)
Whether entry presents on given bookie index.(package private) static DistributionSchedule.WriteSet
writeSetFromValues(java.lang.Integer... values)
-
-
-
Method Detail
-
getWriteSet
public DistributionSchedule.WriteSet getWriteSet(long entryId)
Description copied from interface:DistributionSchedule
Return the set of bookie indices to send the message to.- Specified by:
getWriteSet
in interfaceDistributionSchedule
-
getWriteSetBookieIndex
public int getWriteSetBookieIndex(long entryId, int writeSetIndex)
Description copied from interface:DistributionSchedule
Return the WriteSet bookie index for a given and index in the WriteSet.- Specified by:
getWriteSetBookieIndex
in interfaceDistributionSchedule
- Returns:
-
getEnsembleSet
public DistributionSchedule.WriteSet getEnsembleSet(long entryId)
Description copied from interface:DistributionSchedule
Return the set of bookies indices to send the messages to the whole ensemble.- Specified by:
getEnsembleSet
in 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:DistributionSchedule
Returns an ackset object, responses should be checked against this.- Specified by:
getAckSet
in interfaceDistributionSchedule
-
getEnsembleAckSet
public DistributionSchedule.AckSet getEnsembleAckSet()
Description copied from interface:DistributionSchedule
Returns an ackset object useful to wait for all bookies in the ensemble, responses should be checked against this.- Specified by:
getEnsembleAckSet
in interfaceDistributionSchedule
-
getCoverageSet
public DistributionSchedule.QuorumCoverageSet getCoverageSet()
- Specified by:
getCoverageSet
in interfaceDistributionSchedule
-
hasEntry
public boolean hasEntry(long entryId, int bookieIndex)
Description copied from interface:DistributionSchedule
Whether entry presents on given bookie index.- Specified by:
hasEntry
in 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:DistributionSchedule
Get 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:
getEntriesStripedToTheBookie
in 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:
getWriteQuorumSize
in interfaceDistributionSchedule
-
-