Skip to content

Commit

Permalink
[fix] [broker] do not filter system topic while shedding. (#18949)
Browse files Browse the repository at this point in the history
### Motivation

Currently, topics/bundles in `pulsar/system` will be filter while doing shedding, which is introduced by mistake by pr #15252.
But we need to unload topics/bundles in `pulsar/system` for load balancing. 

### Modifications

do not filter topics/bundles in `pulsar/system`.
  • Loading branch information
thetumbled authored May 31, 2023
1 parent fb1b46e commit 5c74d20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Map<String, BundleData> getBundleData() {

public Map<String, BundleData> getBundleDataForLoadShedding() {
return bundleData.entrySet().stream()
.filter(e -> !NamespaceService.isSystemServiceNamespace(
.filter(e -> !NamespaceService.filterNamespaceForShedding(
NamespaceBundle.getBundleNamespace(e.getKey())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,17 @@ public static boolean isSystemServiceNamespace(String namespace) {
|| HEARTBEAT_NAMESPACE_PATTERN_V2.matcher(namespace).matches();
}

/**
* used for filtering bundles in special namespace.
* @param namespace
* @return True if namespace is HEARTBEAT_NAMESPACE or SLA_NAMESPACE
*/
public static boolean filterNamespaceForShedding(String namespace) {
return SLA_NAMESPACE_PATTERN.matcher(namespace).matches()
|| HEARTBEAT_NAMESPACE_PATTERN.matcher(namespace).matches()
|| HEARTBEAT_NAMESPACE_PATTERN_V2.matcher(namespace).matches();
}

public static boolean isHeartbeatNamespace(ServiceUnitId ns) {
String namespace = ns.getNamespaceObject().toString();
return HEARTBEAT_NAMESPACE_PATTERN.matcher(namespace).matches()
Expand Down

0 comments on commit 5c74d20

Please sign in to comment.