Skip to content

Commit

Permalink
add switch for enable/disable distribute bundles evenly (apache#16059)
Browse files Browse the repository at this point in the history
  • Loading branch information
HQebupt authored Jun 24, 2022
1 parent c871d24 commit b06e78e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,14 @@ public class ServiceConfiguration implements PulsarConfiguration {
+ " should be offload from some over-loaded broker to other under-loaded brokers"
)
private int loadBalancerSheddingIntervalMinutes = 1;

@FieldContext(
dynamic = true,
category = CATEGORY_LOAD_BALANCER,
doc = "enable/disable distribute bundles evenly"
)
private boolean loadBalancerDistributeBundlesEvenlyEnabled = true;

@FieldContext(
category = CATEGORY_LOAD_BALANCER,
dynamic = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,17 @@ public Optional<String> selectBrokerForAssignment(final ServiceUnitId serviceUni
LoadManagerShared.filterAntiAffinityGroupOwnedBrokers(pulsar, serviceUnit.toString(),
brokerCandidateCache,
brokerToNamespaceToBundleRange, brokerToFailureDomainMap);
// distribute bundles evenly to candidate-brokers

LoadManagerShared.removeMostServicingBrokersForNamespace(serviceUnit.toString(), brokerCandidateCache,
brokerToNamespaceToBundleRange);
// distribute bundles evenly to candidate-brokers if enable
if (conf.isLoadBalancerDistributeBundlesEvenlyEnabled()) {
LoadManagerShared.removeMostServicingBrokersForNamespace(serviceUnit.toString(),
brokerCandidateCache,
brokerToNamespaceToBundleRange);
if (log.isDebugEnabled()) {
log.debug("enable distribute bundles evenly to candidate-brokers, broker candidate count={}",
brokerCandidateCache.size());
}
}
log.info("{} brokers being considered for assignment of {}", brokerCandidateCache.size(), bundle);

// Use the filter pipeline to finalize broker candidates.
Expand Down

0 comments on commit b06e78e

Please sign in to comment.