-
Notifications
You must be signed in to change notification settings - Fork 119
[ISSUE #150] sink support topic tag #151
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,25 +19,30 @@ | |
| package org.apache.rocketmq.connect.runtime.config; | ||
|
|
||
| import com.google.common.base.Splitter; | ||
| import java.util.HashSet; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.Map; | ||
| import org.apache.commons.collections4.CollectionUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.rocketmq.common.message.MessageQueue; | ||
| import org.apache.rocketmq.connect.runtime.common.ConnectKeyValue; | ||
|
|
||
| public class SinkConnectorConfig extends ConnectConfig { | ||
|
|
||
|
|
||
|
|
||
| public static Set<String> parseTopicList(ConnectKeyValue taskConfig) { | ||
| String messageQueueStr = taskConfig.getString(RuntimeConfigDefine.CONNECT_TOPICNAME); | ||
| if (StringUtils.isBlank(messageQueueStr)) { | ||
| return null; | ||
| public static Map<String, String> parseTopicList(ConnectKeyValue taskConfig) { | ||
| String topicNameAndTagss = taskConfig.getString(RuntimeConfigDefine.CONNECT_TOPICNAME); | ||
| List<String> topicTagList = Splitter.on(COMMA).omitEmptyStrings().trimResults().splitToList(topicNameAndTagss); | ||
| Map<String, String> topicNameAndTagssMap = new HashMap<>(8); | ||
| for (String topicTagPair : topicTagList) { | ||
| List<String> topicAndTag = Splitter.on(SEMICOLON).omitEmptyStrings().trimResults().splitToList(topicTagPair); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, exchange COMMA and SEMICOLON to maintain upgrade compatible.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there is no tag, if you configure multiple topics, it should be topic1, topic2, topic3. If there is a tag, it should be topic1;tag1, topic2;tag2, topic3;tag3, if so, is there no compatibility problem? |
||
| if (topicAndTag.size() == 1) { | ||
| topicNameAndTagssMap.put(topicAndTag.get(0), "*"); | ||
| } else { | ||
| topicNameAndTagssMap.put(topicAndTag.get(0), topicAndTag.get(1)); | ||
| } | ||
| } | ||
| List<String> topicList = Splitter.on(SEMICOLON).omitEmptyStrings().trimResults().splitToList(messageQueueStr); | ||
| return new HashSet<>(topicList); | ||
| return topicNameAndTagssMap; | ||
| } | ||
|
|
||
| public static MessageQueue parseMessageQueueList(String messageQueueStr) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.