You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/04 14:23:59 UTC

[GitHub] [pulsar] nahguam commented on a diff in pull request #16901: [feat][broker] PIP-157 Bucketing topic metadata to allow more topics per namespace

nahguam commented on code in PR #16901:
URL: https://github.com/apache/pulsar/pull/16901#discussion_r937848649


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -1219,7 +1220,11 @@ private CompletableFuture<List<String>> getPartitionsForTopic(TopicName topicNam
     }
 
     public CompletableFuture<List<String>> getListOfPersistentTopics(NamespaceName namespaceName) {
-        return pulsar.getPulsarResources().getTopicResources().listPersistentTopicsAsync(namespaceName);
+        return pulsar.getPulsarResources().getTopicResources().listPersistentTopicsAsync(namespaceName)
+                .thenApply(x -> {
+                    LOG.info("getListOfPersistentTopics: " + x);

Review Comment:
   Does this need to be info? 
   
   (also `x` -> `topics`)



##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java:
##########
@@ -41,22 +42,29 @@ public class TopicResources {
     private static final String MANAGED_LEDGER_PATH = "/managed-ledgers";
 
     private final MetadataStore store;
+    private final NamespaceResources namespaceResources;
 
     private final Map<BiConsumer<String, NotificationType>, Pattern> topicListeners;
 
-    public TopicResources(MetadataStore store) {
+    public TopicResources(MetadataStore store, NamespaceResources namespaceResources) {
         this.store = store;
+        this.namespaceResources = namespaceResources;
         topicListeners = new ConcurrentHashMap<>();
         store.registerListener(this::handleNotification);
     }
 
     public CompletableFuture<List<String>> listPersistentTopicsAsync(NamespaceName ns) {
         String path = MANAGED_LEDGER_PATH + "/" + ns + "/persistent";
 
-        return store.getChildren(path).thenApply(children ->
-                children.stream().map(c -> TopicName.get(TopicDomain.persistent.toString(), ns, decode(c)).toString())
-                        .collect(Collectors.toList())
-        );
+        CompletableFuture<List<String>> childrenOfNamespace = store.getChildren(path);
+        CompletableFuture<List<String>> topics = childrenOfNamespace.thenCompose(children ->
+                !children.isEmpty() && children.get(0).startsWith(TopicName.BUCKET_ID_PERFIX)
+                        ? children.stream().map(bucket -> store.getChildren(path + "/" + bucket))
+                            .collect(FutureUtil.toList())
+                        : CompletableFuture.completedFuture(children));

Review Comment:
   This looks identical to L76-81, could they share a common helper method?



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org