pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rdhabalia commented on a change in pull request #2972: Introduce `Client.getPartitionsForTopic()`
Date Mon, 12 Nov 2018 22:04:24 GMT
rdhabalia commented on a change in pull request #2972: Introduce `Client.getPartitionsForTopic()`
URL: https://github.com/apache/pulsar/pull/2972#discussion_r232828497
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
 ##########
 @@ -805,6 +807,22 @@ public void reloadLookUp() throws PulsarClientException {
         return metadataFuture;
     }
 
+    @Override
+    public CompletableFuture<List<String>> getPartitionsForTopic(String topic)
{
+        return getPartitionedTopicMetadata(topic).thenApply(metadata -> {
+            if (metadata.partitions > 1) {
+                TopicName topicName = TopicName.get(topic);
+                List<String> partitions = new ArrayList<>(metadata.partitions);
+                for (int i = 0; i < metadata.partitions; i++) {
+                    partitions.add(topicName.getPartition(i).toString());
+                }
+                return partitions;
+            } else {
+                return Collections.singletonList(topic);
 
 Review comment:
   ok.. but I think it might not be difficult or complex for client to handle it. exception
might be helpful to client if client wants to handle non-partition topic differently. as method
name suggests `getPartitionsForTopic(..)` client may expects partitioned-topics in response.

   However, if we still want to return non-partitioned-topic then probably we can add documentation
to clarify the behavior.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message