[FLINK-37436] Fix that flink-connector-pulsar used a incorrect API when dynamically creating topics by DynamicTopicRouter#104
Open
poorbarcode wants to merge 2 commits intoapache:mainfrom
Conversation
…en dynamically creating topics by DynamicTopicRouter
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html) |
Comment on lines
+225
to
+227
| pulsarClient | ||
| .getPartitionsForTopic(TopicName.get(topic).getPartitionedTopicName()) | ||
| .get(); |
Contributor
There was a problem hiding this comment.
It seems to me this could be simplified to:
pulsarClient.getPartitionsForTopic(topicName.getPartitionedTopicName()).get();| .getPartitionsForTopic(TopicName.get(topic).getPartitionedTopicName()) | ||
| .get(); | ||
| } | ||
| // Step-2: create partition. |
Contributor
There was a problem hiding this comment.
Shouldn't step 2 inside an else branch? I don't know anything about the pulsar client but duplicating this call does not seem right.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of the change
Background 1: dynamically create a Pulsar Topic by Flink connector-pulsar
Flink connector-pulsar provided a way to dynamically create a Pulsar Topic when DynamicTopicRouter returns a non-existing one. see also: flink-connector-pulsar/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/sink/writer/topic/ProducerRegister.java at main · apache/flink-connector-pulsar.
pulsarClient.getPartitionsForTopic(topic)will create a topic automatically if it does not exist.Background 2: how dynamically created topics in Pulsar Server
allowAutoTopicCreationType, which can be set topartitionedornon-partitionedpartitioned, Pulsar will create a partitioned topic with{defaultNumPartitions}partitions. For example, Pulsar will create topics named{tenant}/{namespace}/{topic name}-partition-0and{tenant}/{namespace}/{topic name}-partition-1, and create a relationship between them, which indicates they are in a same partitioned topic.non-partitioned, Pulsar will create a non-partitioned topic. Pulsar will create topics named{tenant}/{namespace}/{topic name}, which does not include a suffixpartition-{num}.Issue:
pulsarClient.getPartitionsForTopic(topic)get a param{tenant}/{namespace}/{topic name}-partition-0, which includes the suffixpartition-0, Pulsar will create a non-partitioned topic named{tenant}/{namespace}/{topic name}-partition-0pulsarClient.getPartitionsForTopic(topic)with a param{tenant}/{namespace}/{topic name}-partition-1, you will get two partitions named{tenant}/{namespace}/{topic name}-partition-0and{tenant}/{namespace}/{topic name}-partition-1, but there is no relationship record between them.Relates to https://issues.apache.org/jira/projects/FLINK/issues/FLINK-37436
Brief change log
Fix the incorrect API calling.
Verifying this change
This change is a minor change and don't have any tests.
Significant changes
(Please check any boxes [x] if the answer is "yes". You can first publish the PR and check them afterwards, for
convenience.)
@Public(Evolving))