Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Connector-v2][PulsarSource]Fix pulsar option topic-pattern bug. #3989

Merged
merged 3 commits into from
Feb 4, 2023

Conversation

lightzhao
Copy link
Contributor

Purpose of this pull request

When the user does not set the topic-pattern option, it should be judged whether there is a setting, otherwise the following exception will appear.
image

Check list

@TaoZex
Copy link
Contributor

TaoZex commented Jan 23, 2023

Is topic-pattern a required parameter?

@lightzhao
Copy link
Contributor Author

Is topic-pattern a required parameter?

It's not required parameter.

EricJoy2048
EricJoy2048 previously approved these changes Jan 30, 2023
Comment on lines 213 to 223
if (StringUtils.isNotBlank(topic)) {
this.partitionDiscoverer = new TopicListDiscoverer(Arrays.asList(StringUtils.split(topic, ",")));
}
String topicPattern = config.getString(TOPIC_PATTERN.key());
if (StringUtils.isNotBlank(topicPattern)) {
if (this.partitionDiscoverer != null) {
throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
if (config.hasPath(TOPIC_PATTERN.key())) {
String topicPattern = config.getString(TOPIC_PATTERN.key());
if (StringUtils.isNotBlank(topicPattern)) {
if (this.partitionDiscoverer != null) {
throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
}
this.partitionDiscoverer = new TopicPatternDiscoverer(Pattern.compile(topicPattern));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these two parameters are mutually exclusive, we should prompt the user during the check phase, not here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean. I just judge whether the topic-pattern parameter is configured.

Hisoka-X
Hisoka-X previously approved these changes Jan 30, 2023
Comment on lines 219 to 221
if (this.partitionDiscoverer != null) {
throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if these two parameters are mutually exclusive, then they should be verified in the check phase, not here. so it is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the judgment here also belongs to the check phase.

Comment on lines 219 to 221
if (this.partitionDiscoverer != null) {
throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if these two parameters are mutually exclusive, then they should be verified in the check phase, not here. so it is redundant.

if (StringUtils.isNotBlank(topicPattern)) {
if (this.partitionDiscoverer != null) {
throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
if (config.hasPath(TOPIC_PATTERN.key())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusive configuration of these two parameters has been added.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

back to this question. #3989 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, redundancy judgment deleted.

@lightzhao
Copy link
Contributor Author

@EricJoy2048 @Hisoka-X PTAL

@Hisoka-X Hisoka-X requested a review from CalvinKirs February 3, 2023 02:10
@lightzhao lightzhao dismissed stale reviews from Hisoka-X and EricJoy2048 via f72d2d6 February 3, 2023 09:10
@lightzhao lightzhao requested review from EricJoy2048 and CalvinKirs and removed request for CalvinKirs and EricJoy2048 February 3, 2023 09:38
@@ -213,12 +213,11 @@ private void setPartitionDiscoverer(Config config) {
if (StringUtils.isNotBlank(topic)) {
this.partitionDiscoverer = new TopicListDiscoverer(Arrays.asList(StringUtils.split(topic, ",")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

topic should use config.hasPath(TOPIC_PATTERN.key() judge whether there is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@Hisoka-X Hisoka-X merged commit aee2c58 into apache:dev Feb 4, 2023
@lightzhao lightzhao deleted the pulsar-option-topic-pattern-bug branch February 22, 2023 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants