nicoloboschi commented on code in PR #17522:
URL: https://github.com/apache/pulsar/pull/17522#discussion_r1004673520


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java:
##########
@@ -68,6 +70,49 @@
 @Slf4j
 public abstract class TransactionsBase extends AdminResource {
 
+    protected void internalListCoordinators(AsyncResponse asyncResponse) {
+        final PulsarAdmin admin;
+        try {
+            admin = pulsar().getAdminClient();
+        } catch (PulsarServerException ex) {
+            asyncResponse.resume(new RestException(ex));
+            return;
+        }
+        Map<Integer, TransactionCoordinatorInfo> result = new HashMap<>();
+        admin.lookups()
+                
.lookupPartitionedTopicAsync(SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.getPartitionedTopicName())
+                .thenCompose(map -> {
+                    map.forEach((topicPartition, brokerServiceUrl) -> {
+                        final int coordinatorId = 
TopicName.getPartitionIndex(topicPartition);
+                        result.put(coordinatorId, new 
TransactionCoordinatorInfo(coordinatorId, brokerServiceUrl));
+                    });
+
+                    return getPulsarResources()
+                            .getTopicResources()
+                            
.getExistingPartitions(SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN);
+                })
+                .thenAccept(allPartitions -> {
+                    allPartitions
+                            .stream()
+                            .filter(partition -> SystemTopicNames
+                                    
.isTransactionCoordinatorAssign(TopicName.get(partition)))
+                            .forEach(partition -> {
+                                final int coordinatorId = 
TopicName.getPartitionIndex(partition);
+                                if (!result.containsKey(coordinatorId)) {
+                                    result.put(coordinatorId,
+                                            new 
TransactionCoordinatorInfo(coordinatorId, null));
+                                }
+                            });
+                    asyncResponse.resume(result.values());

Review Comment:
   Because there may be partitions not currently loaded by any broker but it's 
valuable for the user to know that exists 



-- 
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]

Reply via email to