bookkeeper
bookkeeper copied to clipboard
Refactor addDefaultRackBookiesIfMinNumRacksIsEnforced to Remove Redundant Logic
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 fromexcludeBookies. - Remove unnecessary null checks for
bookiesInDefaultRack.
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.
@eolivelli Help review this PR
reopen due to https://github.com/apache/bookkeeper/pull/4665