yzang commented on a change in pull request #883: Issue 709: Add Slow
Bookkeeper Servers to Placement Policy for read ordering
URL: https://github.com/apache/bookkeeper/pull/883#discussion_r157646148
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
##########
@@ -836,15 +922,54 @@ protected BookieNode selectRandomFromRack(String
netPath, Set<Node> excludeBooki
if (reorderReadsRandom) {
shuffleWithMask(writeSet, LOCAL_MASK, MASK_BITS);
+ shuffleWithMask(writeSet, REMOTE_MASK, MASK_BITS);
shuffleWithMask(writeSet, READ_ONLY_MASK, MASK_BITS);
shuffleWithMask(writeSet, UNAVAIL_MASK, MASK_BITS);
}
- // remove all masks
+ // nodes within a region are ordered as follows
+ // (Random?) list of nodes that have no history of failure
+ // Nodes with Failure history are ordered in the reverse
+ // order of the most recent entry that generated an error
+ // The sort will have put them in correct order,
+ // so remove the bits that sort by age.
+ for (int i = 0; i < writeSet.size(); i++) {
+ int mask = writeSet.get(i) & MASK_BITS;
+ int idx = (writeSet.get(i) & ~MASK_BITS) % ensembleSize;
+ if (mask == LOCAL_FAIL_MASK) {
+ writeSet.set(i, LOCAL_MASK | idx);
+ } else if (mask == REMOTE_FAIL_MASK) {
+ writeSet.set(i, REMOTE_MASK | idx);
+ } else if (mask == SLOW_MASK) {
+ writeSet.set(i, SLOW_MASK | idx);
+ }
+ }
+
+ // Insert a node from the remote region at the specified location so
+ // we try more than one region within the max allowed latency
+ int firstRemote = -1;
for (int i = 0; i < writeSet.size(); i++) {
- writeSet.set(i, (writeSet.get(i) & ~MASK_BITS) % ensembleSize);
+ if ((writeSet.get(i) & MASK_BITS) == REMOTE_MASK) {
+ firstRemote = i;
+ break;
+ }
+ }
+ if (firstRemote != -1) {
+ int i = 0;
+ for (;i < remoteNodeInReorderSequence
Review comment:
We can simplify here? for(i=0; i<...; i++)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services