liangyepianzhou commented on code in PR #4652:
URL: https://github.com/apache/bookkeeper/pull/4652#discussion_r2430967092


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java:
##########
@@ -359,30 +359,22 @@ public void uninitalize() {
      */
     protected Set<BookieId> addDefaultRackBookiesIfMinNumRacksIsEnforced(
             Set<BookieId> excludeBookies) {
-        Set<BookieId> comprehensiveExclusionBookiesSet;
-        if (enforceMinNumRacksPerWriteQuorum) {
-            Set<BookieId> bookiesInDefaultRack = null;
-            Set<Node> defaultRackLeaves = topology.getLeaves(getDefaultRack());
-            for (Node node : defaultRackLeaves) {
-                if (node instanceof BookieNode) {
-                    if (bookiesInDefaultRack == null) {
-                        bookiesInDefaultRack = new 
HashSet<BookieId>(excludeBookies);
-                    }
-                    bookiesInDefaultRack.add(((BookieNode) node).getAddr());
-                } else {
-                    LOG.error("found non-BookieNode: {} as leaf of 
defaultrack: {}", node, getDefaultRack());
-                }
-            }
-            if ((bookiesInDefaultRack == null) || 
bookiesInDefaultRack.isEmpty()) {
-                comprehensiveExclusionBookiesSet = excludeBookies;
+        if (!enforceMinNumRacksPerWriteQuorum) {
+            return excludeBookies;
+        }
+
+        Set<BookieId> comprehensiveExclusionBookiesSet = new 
HashSet<>(excludeBookies);
+        Set<Node> defaultRackLeaves = topology.getLeaves(getDefaultRack());
+        for (Node node : defaultRackLeaves) {
+            if (node instanceof BookieNode) {
+                comprehensiveExclusionBookiesSet.add(((BookieNode) 
node).getAddr());
             } else {
-                comprehensiveExclusionBookiesSet = new 
HashSet<BookieId>(excludeBookies);
-                comprehensiveExclusionBookiesSet.addAll(bookiesInDefaultRack);
-                LOG.info("enforceMinNumRacksPerWriteQuorum is enabled, so 
Excluding bookies of defaultRack: {}",
-                        bookiesInDefaultRack);
+                LOG.error("found non-BookieNode: {} as leaf of defaultrack: 
{}", node, getDefaultRack());
             }
-        } else {
-            comprehensiveExclusionBookiesSet = excludeBookies;
+        }
+        if (!comprehensiveExclusionBookiesSet.isEmpty()) {
+            LOG.info("enforceMinNumRacksPerWriteQuorum is enabled, so 
Excluding bookies of defaultRack: {}",

Review Comment:
   You are right, the original log content was not accurate, and we should not 
keep it the same as before. 
   Previously, the log printed the union of excludeBookies and all BookieIds 
under the default rack, but in fact, the intended meaning of the log is the 
BookieIds that are under the default rack.



-- 
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