horizonzy commented on code in PR #4013:
URL: https://github.com/apache/bookkeeper/pull/4013#discussion_r1251598383


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java:
##########
@@ -482,16 +490,33 @@ public PlacementResult<BookieId> replaceBookie(int 
ensembleSize, int writeQuorum
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Try to choose a new bookie to replace {} from 
ensemble {}, excluding {}.",
-                    bookieToReplace, ensembleNodes, excludeNodes);
+                        bookieToReplace, ensembleNodes, excludeNodes);
             }
             // pick a candidate from same rack to replace
-            BookieNode candidate = selectFromNetworkLocation(
-                    bn.getNetworkLocation(),
-                    networkLocationsToBeExcluded,
-                    excludeNodes,
-                    TruePredicate.INSTANCE,
-                    EnsembleForReplacementWithNoConstraints.INSTANCE,
-                    !enforceMinNumRacksPerWriteQuorum);
+            BookieNode candidate;
+            try {
+                candidate = selectFromNetworkLocation(
+                        bn.getNetworkLocation(),
+                        networkLocationsToBeExcluded,
+                        excludeNodes,
+                        TruePredicate.INSTANCE,
+                        EnsembleForReplacementWithNoConstraints.INSTANCE,
+                        !enforceMinNumRacksPerWriteQuorum);
+            } catch (BKNotEnoughBookiesException e) {
+                if (downgradeToSelf) {
+                    candidate = knownBookies.get(bookieToReplace);

Review Comment:
   > We need to ensure the bookie is writable. The knownBookies set contains 
all the bookies which are writable and read-only.
   
   No, the knownBookies only contain writable bookies. The readOnlyBookies will 
store the read-only bookies.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to