Issue 1898: Implement isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy#4133
Issue 1898: Implement isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy#4133dragonls wants to merge 5 commits intoapache:masterfrom
isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy#4133Conversation
|
@horizonzy Please help take a look at this PR, thanks. |
|
@dragonls Thanks for your contribution. Would you please fix the failed check style? thanks. |
Fixed. |
...er-server/src/main/java/org/apache/bookkeeper/client/RegionAwareEnsemblePlacementPolicy.java
Show resolved
Hide resolved
...er-server/src/main/java/org/apache/bookkeeper/client/RegionAwareEnsemblePlacementPolicy.java
Outdated
Show resolved
Hide resolved
| return PlacementPolicyAdherence.FAIL; | ||
| } | ||
|
|
||
| if (regionsInQuorum.size() < 2) { |
There was a problem hiding this comment.
I have a question: why judge the regionsInQuorum.size() < 2?
There was a problem hiding this comment.
The purpose of doing this here is to align the implement in org.apache.bookkeeper.client.RegionAwareEnsemblePlacementPolicy#newEnsemble:
When there is only one available region, fall back to RackAwareEnsemblePlacement.
There was a problem hiding this comment.
It's a little weird.
Based on: writeQuorumSize = 3.
If regionsInQuorum < 2, the result may be MEETS_STRICT.
If regionsInQuorum = 2, the result is FAIL.
There was a problem hiding this comment.
Yes, a little weird.
Should we just remove the numRegionsAvailable < 2 judge in isEnsembleAdheringToPlacementPolicy? May I have your suggestion?
There was a problem hiding this comment.
The PlacementPolicyAdherence enum has three values FAIL(1), MEETS_SOFT(3), MEETS_STRICT(5).
If there are enough different region, the result could be MEETS_STRICT. If there aren't enough different region, the each RackAwarePLacementPolicy MEETS_STRICT, the result could be MEETS_SOFT
| PlacementResult<List<BookieId>> placementResult = nextPolicy.newEnsemble(ensembleSize, writeQuorumSize, writeQuorumSize, | ||
| comprehensiveExclusionBookiesSet, ensemble, ensemble); | ||
| return PlacementResult.of(placementResult.getResult(), | ||
| isEnsembleAdheringToPlacementPolicy( |
There was a problem hiding this comment.
Here, we can simplify the logic. We already know there is only one region.
Just need check the result of nextPolicy.newEnsemble.
- If the result is PlacementPolicyAdherence.FAIL, return directly.
- If the result is PlacementPolicyAdherence.MEETS_STRICT, then check whether minNumRacksPerWriteQuorum is more than 1. If it is, return PlacementPolicyAdherence.SOFT, otherwise return PlacementPolicyAdherence.MEETS_STRICT.
Master Issue: #1898
Motivation
Before this PR,
isEnsembleAdheringToPlacementPolicyinRegionAwareEnsemblePlacementPolicyalways returnPlacementPolicyAdherence.MEETS_STRICT, which is not good to keep data highly available while usingRegionAwareEnsemblePlacementPolicy, especially when one region is down.Changes
Implement
isEnsembleAdheringToPlacementPolicyinRegionAwareEnsemblePlacementPolicy.The main implementation idea is that when all allocations are satisfied in different regions, it is considered
PlacementPolicyAdherence.MEETS_STRICT, otherwisePlacementPolicyAdherence.FAIL.