Skip to content

Commit

Permalink
[pulsar-broker] load-balancer support disabling max-session for bundl…
Browse files Browse the repository at this point in the history
…e split (#13108)
  • Loading branch information
rdhabalia committed Dec 20, 2021
1 parent c62ca80 commit f7abada
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ loadBalancerAutoUnloadSplitBundlesEnabled=true
loadBalancerNamespaceBundleMaxTopics=1000

# maximum sessions (producers + consumers) in a bundle, otherwise bundle split will be triggered
# (disable threshold check with value -1)
loadBalancerNamespaceBundleMaxSessions=1000

# maximum msgRate (in + out) in a bundle, otherwise bundle split will be triggered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,7 @@ public class ServiceConfiguration implements PulsarConfiguration {
@FieldContext(
category = CATEGORY_LOAD_BALANCER,
doc = "maximum sessions (producers + consumers) in a bundle, otherwise bundle split will be triggered"
+ "(disable threshold check with value -1)"
)
private int loadBalancerNamespaceBundleMaxSessions = 1000;
@FieldContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public Set<String> findBundlesToSplit(final LoadData loadData, final PulsarServi
totalMessageRate = longTermData.totalMsgRate();
totalMessageThroughput = longTermData.totalMsgThroughput();
}
if (stats.topics > maxBundleTopics || stats.consumerCount + stats.producerCount > maxBundleSessions
if (stats.topics > maxBundleTopics || (maxBundleSessions > 0 && (stats.consumerCount
+ stats.producerCount > maxBundleSessions))
|| totalMessageRate > maxBundleMsgRate || totalMessageThroughput > maxBundleBandwidth) {
final String namespace = LoadManagerShared.getNamespaceNameFromBundleName(bundle);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,8 @@ public void doNamespaceBundleSplit() throws Exception {
double totalBandwidth = stats.msgThroughputIn + stats.msgThroughputOut;

boolean needSplit = false;
if (stats.topics > maxBundleTopics || totalSessions > maxBundleSessions || totalMsgRate > maxBundleMsgRate
if (stats.topics > maxBundleTopics || (maxBundleSessions > 0
&& totalSessions > maxBundleSessions) || totalMsgRate > maxBundleMsgRate
|| totalBandwidth > maxBundleBandwidth) {
if (stats.topics <= 1) {
log.info("Unable to split hot namespace bundle {} since there is only one topic.", bundleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ public void testNamespaceBundleAutoSplit() throws Exception {
isAutoUnooadSplitBundleEnabled, null);
verify(namespaceAdmin, never()).splitNamespaceBundle("pulsar/use/primary-ns-10", "0x00000000_0x02000000",
isAutoUnooadSplitBundleEnabled, null);
// disable max session
bundleStats.put("pulsar/use/primary-ns-03/0x00000000_0x80000000",
newBundleStats(2, -1, 0, 0, 0, 0, 0));
verify(namespaceAdmin, times(0)).splitNamespaceBundle("pulsar/use/primary-ns-12", "0x00000000_0x80000000",
isAutoUnooadSplitBundleEnabled, null);
}

/*
Expand Down

0 comments on commit f7abada

Please sign in to comment.