Pomelongan commented on code in PR #17946:
URL: https://github.com/apache/pulsar/pull/17946#discussion_r991846990
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -4552,6 +4555,75 @@ private CompletableFuture<Void>
createSubscriptions(TopicName topicName, int num
return result;
}
+ /**
+ * It creates subscriptions for new partitions of existing
partitioned-topics.
+ *
+ * @param topicName : topic-name: persistent://prop/cluster/ns/topic
+ * @param numPartitions : number partitions for the topics
+ *
+ */
+ private CompletableFuture<Void> createMissedSubscriptionsAsync(TopicName
topicName, int numPartitions) {
+ CompletableFuture<Void> result = new CompletableFuture<>();
+ PulsarAdmin admin;
+ try {
+ admin = pulsar().getAdminClient();
+ } catch (PulsarServerException e1) {
+ result.completeExceptionally(e1);
+ return result;
+ }
+
admin.topics().getStatsAsync(topicName.getPartition(0).toString()).thenAccept(stats
-> {
Review Comment:
Can I understand this: get the TopicStats of all partitions of the Topic,
and extract the public subscriptions of all TopicStats. If the TopicStats of
the partition exist, do not execute createSubscriptionAsync. If the TopicStats
of the partition do not exist, execute createSubscriptionAsync to create public
subscriptions for the partition.
> The partition-0 maybe also created by the `CreateMissedPartitions`, I
think we should list the subscriptions of the partitioned topic.
> And for Pulsar, users can subscription to a specific partition, which
means partition-0, partition-1 might have different subscriptions.
--
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]