This is an automated email from the ASF dual-hosted git repository.
zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new dc6397093eb [fix][broker] Remove blocking calls from
internalGetPartitionedStats (#23832)
dc6397093eb is described below
commit dc6397093eb645fec1bfd6f127f78ad36be0a360
Author: Zixuan Liu <[email protected]>
AuthorDate: Mon Jan 13 10:39:02 2025 +0800
[fix][broker] Remove blocking calls from internalGetPartitionedStats
(#23832)
Signed-off-by: Zixuan Liu <[email protected]>
---
.../broker/admin/impl/PersistentTopicsBase.java | 30 ++++++++++------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index eed667d4990..e88b1110d0a 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -1522,23 +1522,21 @@ public class PersistentTopicsBase extends AdminResource
{
}
}
if (perPartition && stats.partitions.isEmpty()) {
- try {
- boolean pathExists =
namespaceResources().getPartitionedTopicResources()
- .partitionedTopicExists(topicName);
- if (pathExists) {
- stats.partitions.put(topicName.toString(), new
TopicStatsImpl());
- } else {
- asyncResponse.resume(
- new RestException(Status.NOT_FOUND,
- "Internal topics have not been
generated yet"));
- return null;
- }
- } catch (Exception e) {
- asyncResponse.resume(new RestException(e));
- return null;
- }
+ namespaceResources().getPartitionedTopicResources()
+ .partitionedTopicExistsAsync(topicName)
+ .thenAccept(exists -> {
+ if (exists) {
+ stats.partitions.put(topicName.toString(),
new TopicStatsImpl());
+ asyncResponse.resume(stats);
+ } else {
+ asyncResponse.resume(
+ new RestException(Status.NOT_FOUND,
+ "Internal topics have not
been generated yet"));
+ }
+ });
+ } else {
+ asyncResponse.resume(stats);
}
- asyncResponse.resume(stats);
return null;
});
}).exceptionally(ex -> {