From b425260296d1524d61643b3e286d395df1ed5835 Mon Sep 17 00:00:00 2001 From: Dreaouth Date: Sun, 20 Sep 2020 19:09:29 +0800 Subject: [PATCH] [ISSUE #570] ASoC connect runtime optimization: CLI (#622) feature(rocketmq-runtime) add CLI support for rocketmq-connect-runtime * Add CLI * Fix checkstyle * Optimize CLI structure * Add README.md * Rename CLI * Update pom.xml * Optimize the connectors and tasks format * Fix newline format --- .../jdbc/connector/JdbcSourceConnector.java | 2 +- .../jdbc/strategy/DivideTaskByTopic.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/rocketmq/connect/jdbc/connector/JdbcSourceConnector.java b/src/main/java/org/apache/rocketmq/connect/jdbc/connector/JdbcSourceConnector.java index a083e84b0..ee6213328 100644 --- a/src/main/java/org/apache/rocketmq/connect/jdbc/connector/JdbcSourceConnector.java +++ b/src/main/java/org/apache/rocketmq/connect/jdbc/connector/JdbcSourceConnector.java @@ -59,7 +59,7 @@ public String verifyAndSetConfig(KeyValue config) { @Override public void start() { - + log.info("JdbcSourceConnector start"); } @Override diff --git a/src/main/java/org/apache/rocketmq/connect/jdbc/strategy/DivideTaskByTopic.java b/src/main/java/org/apache/rocketmq/connect/jdbc/strategy/DivideTaskByTopic.java index c1d50207a..576279571 100644 --- a/src/main/java/org/apache/rocketmq/connect/jdbc/strategy/DivideTaskByTopic.java +++ b/src/main/java/org/apache/rocketmq/connect/jdbc/strategy/DivideTaskByTopic.java @@ -41,21 +41,23 @@ private List divideSourceTaskByTopic(DbConnectorConfig dbConnectorConf int parallelism = tdc.getTaskParallelism(); int id = -1; Map topicRouteMap = ((SourceDbConnectorConfig)dbConnectorConfig).getWhiteTopics(); - Map>> taskTopicList = new HashMap<>(); + Map taskTopicList = new HashMap<>(); + Map>> taskWhiteList = new HashMap<>(); for (Map.Entry entry : topicRouteMap.entrySet()) { int ind = ++id % parallelism; - if (!taskTopicList.containsKey(ind)) { - taskTopicList.put(ind, new HashMap<>()); + if (!taskWhiteList.containsKey(ind)) { + taskWhiteList.put(ind, new HashMap<>()); } String dbKey = entry.getKey().split("-")[0]; String tableKey = entry.getKey().split("-")[1]; + taskTopicList.put(ind, tableKey); String filter = entry.getValue(); Map tableMap = new HashMap<>(); tableMap.put(tableKey, filter); - if(!taskTopicList.get(ind).containsKey(dbKey)){ - taskTopicList.get(ind).put(dbKey, tableMap); + if(!taskWhiteList.get(ind).containsKey(dbKey)){ + taskWhiteList.get(ind).put(dbKey, tableMap); }else { - taskTopicList.get(ind).get(dbKey).putAll(tableMap); + taskWhiteList.get(ind).get(dbKey).putAll(tableMap); } } @@ -66,7 +68,8 @@ private List divideSourceTaskByTopic(DbConnectorConfig dbConnectorConf keyValue.put(Config.CONN_DB_PORT, tdc.getDbPort()); keyValue.put(Config.CONN_DB_USERNAME, tdc.getDbUserName()); keyValue.put(Config.CONN_DB_PASSWORD, tdc.getDbPassword()); - keyValue.put(Config.CONN_WHITE_LIST, JSONObject.toJSONString(taskTopicList.get(i))); + keyValue.put(Config.CONN_WHITE_LIST, JSONObject.toJSONString(taskWhiteList.get(i))); + keyValue.put(Config.CONN_TOPIC_NAMES, taskTopicList.get(i)); keyValue.put(Config.CONN_DATA_TYPE, tdc.getDataType()); keyValue.put(Config.CONN_SOURCE_RECORD_CONVERTER, tdc.getSrcRecordConverter()); keyValue.put(Config.CONN_DB_MODE, tdc.getMode());