Commit a5b6830
xiangying
Refactor addDefaultRackBookiesIfMinNumRacksIsEnforced to Remove Redundant Logic and Improve Robustness
### 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.
- **Potential robustness issue**: There is no null check for the address returned by `BookieNode.getAddr()`, which may result in `null` values being included in the exclusion set.
- **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`.
```java
LOG.info("enforceMinNumRacksPerWriteQuorum is enabled, so Excluding bookies of defaultRack: {}", bookiesInDefaultRack);
```
---
### Modification
- When creating `bookiesInDefaultRack`, do not copy elements from `excludeBookies`.
- Add a null check for the address returned by `BookieNode.getAddr()`.
- Remove unnecessary null checks for `bookiesInDefaultRack`.1 parent c9b893f commit a5b6830
File tree
1 file changed
+3
-3
lines changed- bookkeeper-server/src/main/java/org/apache/bookkeeper/client
1 file changed
+3
-3
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
367 | | - | |
| 367 | + | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| |||
0 commit comments