Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,16 @@ public synchronized void addBookie(int bookieIndexHeardFrom, int rc) {
public synchronized boolean checkCovered() {
// now check if there are any write quorums, with |ackQuorum| nodes available
for (int i = 0; i < ensembleSize; i++) {
int nodesNotCovered = 0;
int nodesOkay = 0;
int nodesUninitialized = 0;
for (int j = 0; j < writeQuorumSize; j++) {
int nodeIndex = (i + j) % ensembleSize;
if (covered[nodeIndex] == BKException.Code.OK) {
if ((covered[nodeIndex] == BKException.Code.OK)
|| (covered[nodeIndex] == BKException.Code.NoSuchEntryException)
|| (covered[nodeIndex] == BKException.Code.NoSuchLedgerExistsException)) {
nodesOkay++;
} else if (covered[nodeIndex] != BKException.Code.NoSuchEntryException
&& covered[nodeIndex] != BKException.Code.NoSuchLedgerExistsException) {
nodesNotCovered++;
} else if (covered[nodeIndex] == BKException.Code.UNINITIALIZED) {
nodesUninitialized++;
}
}
// if we haven't seen any OK responses and there are still nodes not heard from,
// let's wait until
if (nodesNotCovered >= ackQuorumSize || (nodesOkay == 0 && nodesUninitialized > 0)) {
if (nodesOkay < ackQuorumSize) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.HashSet;
import java.util.Set;

import org.apache.bookkeeper.client.DistributionSchedule.QuorumCoverageSet;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -161,4 +163,28 @@ public void testMoveAndShift() {
w.moveAndShift(4, 4);
assertEquals(w, writeSetFromValues(1, 2, 3, 4, 5));
}

@Test
public void testRRQuorumCoverageSet() throws Exception {
int ensembleSize = 9;
int writeQuorumSize = 7;
int ackQuorumSize = 5;
RoundRobinDistributionSchedule schedule = new RoundRobinDistributionSchedule(writeQuorumSize, ackQuorumSize,
ensembleSize);
QuorumCoverageSet rrQuorumCoverageSet = schedule.getCoverageSet();
rrQuorumCoverageSet.addBookie(0, BKException.Code.DigestMatchException);
rrQuorumCoverageSet.addBookie(1, BKException.Code.OK);
rrQuorumCoverageSet.addBookie(2, BKException.Code.DigestMatchException);
rrQuorumCoverageSet.addBookie(3, BKException.Code.OK);
rrQuorumCoverageSet.addBookie(4, BKException.Code.DigestMatchException);
rrQuorumCoverageSet.addBookie(5, BKException.Code.OK);
rrQuorumCoverageSet.addBookie(6, BKException.Code.DigestMatchException);
rrQuorumCoverageSet.addBookie(7, BKException.Code.OK);
rrQuorumCoverageSet.addBookie(8, BKException.Code.DigestMatchException);
/*
* since not in any write quorum, there is |ackQuorum| number of OKs,
* so checkcovered should be false
*/
Assert.assertFalse("RRQuorumCoverageSet covered should be false", rrQuorumCoverageSet.checkCovered());
}
}