lordcheng10 commented on code in PR #16557:
URL: https://github.com/apache/pulsar/pull/16557#discussion_r960468128
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -822,13 +824,34 @@ public CompletableFuture<Void>
splitAndOwnBundle(NamespaceBundle bundle, boolean
return unloadFuture;
}
+ public Map<String, TopicStatsImpl> getTopicStats(NamespaceBundle bundle) {
+ ConcurrentOpenHashMap<String, Topic> topicMap =
pulsar.getBrokerService().getMultiLayerTopicMap()
+ .computeIfAbsent(bundle.getNamespaceObject().toString(), k -> {
+ return ConcurrentOpenHashMap
+ .<String, ConcurrentOpenHashMap<String,
Topic>>newBuilder().build();
+ }).computeIfAbsent(bundle.toString(), k -> {
+ return ConcurrentOpenHashMap.<String, Topic>newBuilder().build();
+ });
+
+ Map<String, TopicStatsImpl> topicStatsMap = new HashMap<>();
+ topicMap.forEach((name, topic) -> {
+ topicStatsMap.put(name,
+ topic.getStats(false, false, false));
+ });
+ return topicStatsMap;
+ }
+
void splitAndOwnBundleOnceAndRetry(NamespaceBundle bundle,
boolean unload,
AtomicInteger counter,
CompletableFuture<Void>
completionFuture,
NamespaceBundleSplitAlgorithm
splitAlgorithm,
List<Long> boundaries) {
- BundleSplitOption bundleSplitOption = new BundleSplitOption(this,
bundle, boundaries);
+ Map<String, TopicStatsImpl> topicStatsMap = getTopicStats(bundle);
Review Comment:
fixed.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -822,13 +824,34 @@ public CompletableFuture<Void>
splitAndOwnBundle(NamespaceBundle bundle, boolean
return unloadFuture;
}
+ public Map<String, TopicStatsImpl> getTopicStats(NamespaceBundle bundle) {
+ ConcurrentOpenHashMap<String, Topic> topicMap =
pulsar.getBrokerService().getMultiLayerTopicMap()
+ .computeIfAbsent(bundle.getNamespaceObject().toString(), k -> {
+ return ConcurrentOpenHashMap
+ .<String, ConcurrentOpenHashMap<String,
Topic>>newBuilder().build();
+ }).computeIfAbsent(bundle.toString(), k -> {
+ return ConcurrentOpenHashMap.<String, Topic>newBuilder().build();
+ });
+
+ Map<String, TopicStatsImpl> topicStatsMap = new HashMap<>();
+ topicMap.forEach((name, topic) -> {
+ topicStatsMap.put(name,
+ topic.getStats(false, false, false));
+ });
+ return topicStatsMap;
+ }
+
void splitAndOwnBundleOnceAndRetry(NamespaceBundle bundle,
boolean unload,
AtomicInteger counter,
CompletableFuture<Void>
completionFuture,
NamespaceBundleSplitAlgorithm
splitAlgorithm,
List<Long> boundaries) {
- BundleSplitOption bundleSplitOption = new BundleSplitOption(this,
bundle, boundaries);
+ Map<String, TopicStatsImpl> topicStatsMap = getTopicStats(bundle);
+ BundleSplitOption bundleSplitOption = new BundleSplitOption(this,
bundle, boundaries, topicStatsMap,
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]