[improve][broker]improve the getAntiAffinityNamespaceOwnedBrokers check exclude the current namespace cause count add. #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
As the PIP 7: Pulsar Failure domain and Anti affinity namespaces design, the anti affinity namespaces should be distributed to evenly across all domain and all the brokers.
But in method
getAntiAffinityNamespaceOwnedBrokers
,brokerToAntiAffinityNamespaceCount
add a count even the namespace equal the given bundle's namespace which will be load. The behavior will cause the namespace easy to distributed toa broker which has another namespace in anti affinity group, the behavior broke the anti affinity balance. It's better behavior is the same namespace should be distributed to those broker which has loaded the same namespace when all broker have load at least one namespace in ti affinity group.
there is some case
ns-0 ns-1 ns-2 are all set the same anti affinity group like 'a-group
broker-0
ownns-0 bundle-0
;broker-1
ownns-1 bundle-0
;broker-2
ownns-2 bundle-0
;then another
ns-2 bundle-1
need choice a broker to load. As the old policy,broker-0 broker-1 and broker-2
are all satisfy the least NamespaceCount; but ifns-2 bundle-1
load tobroker-0 or broker-1
will broke the anti affinity balance.ns-2 bundle-1
need be load by broker-2 is better.Also, the behavior will cause give up
doLoadShedding
when the all broker own one namespace in anti affinity group, but the different broker owned namespace bundle count and payload is different.So
brokerToAntiAffinityNamespaceCount
should exclude the given namespace count add.Modifications
getAntiAffinityNamespaceOwnedBrokers
method, exclude the given namespace count add.shouldAntiAffinityNamespaceUnload
check;Documentation
doc-not-needed