bookkeeper icon indicating copy to clipboard operation
bookkeeper copied to clipboard

Refactor addDefaultRackBookiesIfMinNumRacksIsEnforced to Remove Redundant Logic

Open liangyepianzhou opened this issue 4 months ago • 3 comments

Motivation

The current implementation of addDefaultRackBookiesIfMinNumRacksIsEnforced has the following issues:

  • Redundant logic: The initialization and merging process for collecting Bookie nodes on the default rack involves unnecessary data copying and checks.
  • Incorrect logging: The log claims to print only the defaultRack Bookies that are being excluded, while it actually prints all the nodes, including those already in excludeBookies.
LOG.info("enforceMinNumRacksPerWriteQuorum is enabled, so Excluding bookies of defaultRack: {}", bookiesInDefaultRack); 

Modification

  • When creating bookiesInDefaultRack, do not copy elements from excludeBookies.
  • Remove unnecessary null checks for bookiesInDefaultRack.

liangyepianzhou avatar Aug 14 '25 12:08 liangyepianzhou

which test cases are covering this change ?

It seems that there was previously no test coverage for this method, so I have added some test cases for addDefaultRackBookiesIfMinNumRacksIsEnforced.

liangyepianzhou avatar Sep 24 '25 07:09 liangyepianzhou

@eolivelli Help review this PR

StevenLuMT avatar Oct 16 '25 11:10 StevenLuMT

reopen due to https://github.com/apache/bookkeeper/pull/4665

liangyepianzhou avatar Nov 04 '25 06:11 liangyepianzhou