Skip to content

Commit

Permalink
[improve][broker] Use bulk operation instead of iteration (apache#20219)
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiangcc authored May 6, 2023
1 parent 9f7a539 commit 9cb0503
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected CompletableFuture<Map<String, Set<AuthAction>>> internalGetPermissions
String topicUri = topicName.toString();
AuthPolicies auth = policies.get().auth_policies;
// First add namespace level permissions
auth.getNamespaceAuthentication().forEach(permissions::put);
permissions.putAll(auth.getNamespaceAuthentication());

// Then add topic level permissions
if (auth.getTopicAuthentication().containsKey(topicUri)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ private void loadAllResourceGroups() {
final Set<String> existingSet = rgService.resourceGroupGetAll();
HashSet<String> newSet = new HashSet<>();

for (String rgName : rgList) {
newSet.add(rgName);
}
newSet.addAll(rgList);

final Sets.SetView<String> deleteList = Sets.difference(existingSet, newSet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,10 @@ public synchronized void updateStats(
}
});
if (clusterReplicationMetrics.isMetricsEnabled()) {
clusterReplicationMetrics.get().forEach(clusterMetric -> tempMetricsCollection.add(clusterMetric));
tempMetricsCollection.addAll(clusterReplicationMetrics.get());
clusterReplicationMetrics.reset();
}
brokerOperabilityMetrics.getMetrics()
.forEach(brokerOperabilityMetric -> tempMetricsCollection.add(brokerOperabilityMetric));
tempMetricsCollection.addAll(brokerOperabilityMetrics.getMetrics());

// json end
topicStatsStream.endObject();
Expand Down

0 comments on commit 9cb0503

Please sign in to comment.