congbobo184 commented on code in PR #17522:
URL: https://github.com/apache/pulsar/pull/17522#discussion_r1005834193
##########
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:
sorry for late response, lookupPartitionedTopicAsync has already return all
the partition, it will not missing. are you test it will miss?
--
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]