sijie closed pull request #1120: [Merge Yahoo repo]: Only reorder read sequence 
if any bookie is not available
URL: https://github.com/apache/bookkeeper/pull/1120
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
index 7dcd72877..9a587643b 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
@@ -927,6 +927,28 @@ public void registerSlowBookie(BookieSocketAddress 
bookieSocketAddress, long ent
         boolean useRegionAware = regionAware && 
(!myRegion.equals(UNKNOWN_REGION));
         int ensembleSize = ensemble.size();
 
+        // For rack aware, If all the bookies in the write set are available, 
simply return the original write set,
+        // to avoid creating more lists
+        boolean isAnyBookieUnavailable = false;
+
+        if (useRegionAware || reorderReadsRandom) {
+            isAnyBookieUnavailable = true;
+        } else {
+            for (int i = 0; i < ensemble.size(); i++) {
+                BookieSocketAddress bookieAddr = ensemble.get(i);
+                if ((!knownBookies.containsKey(bookieAddr) && 
!readOnlyBookies.contains(bookieAddr))
+                    || slowBookies.getIfPresent(bookieAddr) != null) {
+                    // Found at least one bookie not available in the 
ensemble, or in slowBookies
+                    isAnyBookieUnavailable = true;
+                    break;
+                }
+            }
+        }
+
+        if (!isAnyBookieUnavailable) {
+            return writeSet;
+        }
+
         for (int i = 0; i < writeSet.size(); i++) {
             int idx = writeSet.get(i);
             BookieSocketAddress address = ensemble.get(idx);
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
index 01a6617fd..bb7c6928e 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
@@ -182,10 +182,8 @@ public void testNodeReadOnly() throws Exception {
         DistributionSchedule.WriteSet origWriteSet = writeSet.copy();
         DistributionSchedule.WriteSet reorderSet = repp.reorderReadSequence(
                 ensemble, getBookiesHealthInfo(), writeSet);
-        DistributionSchedule.WriteSet expectedSet = writeSetFromValues(1, 2, 
3, 0);
         LOG.info("reorder set : {}", reorderSet);
-        assertFalse(reorderSet.equals(origWriteSet));
-        assertEquals(expectedSet, reorderSet);
+        assertEquals(reorderSet, origWriteSet);
     }
 
     @Test
@@ -914,6 +912,12 @@ public void testNodeWithFailures() throws Exception {
         bookieFailures.put(addr1, 20L);
         bookieFailures.put(addr2, 22L);
 
+        // remove failure bookies: addr1 and addr2
+        addrs = new HashSet<BookieSocketAddress>();
+        addrs.add(addr3);
+        addrs.add(addr4);
+        repp.onClusterChanged(addrs, new HashSet<BookieSocketAddress>());
+
         DistributionSchedule.WriteSet reoderSet = repp.reorderReadSequence(
                 ensemble, getBookiesHealthInfo(bookieFailures, new 
HashMap<>()), writeSet);
         LOG.info("reorder set : {}", reoderSet);


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to