use of org.apache.rocketmq.connect.jdbc.config.TaskTopicInfo in project rocketmq-externals by apache.
the class JdbcSinkConnector method buildRoute.
public void buildRoute() {
String srcCluster = ((SinkDbConnectorConfig) this.dbConnectorConfig).getSrcCluster();
try {
for (String topic : ((SinkDbConnectorConfig) this.dbConnectorConfig).getWhiteList()) {
// different from BrokerData with cluster field, which can ensure the brokerData is from expected cluster.
// QueueData use brokerName as unique info on cluster of rocketmq. so when we want to get QueueData of
// expected cluster, we should get brokerNames of expected cluster, and then filter queueDatas.
List<BrokerData> brokerList = Utils.examineBrokerData(this.srcMQAdminExt, topic, srcCluster);
Set<String> brokerNameSet = new HashSet<String>();
for (BrokerData b : brokerList) {
brokerNameSet.add(b.getBrokerName());
}
TopicRouteData topicRouteData = srcMQAdminExt.examineTopicRouteInfo(topic);
if (!topicRouteMap.containsKey(topic)) {
topicRouteMap.put(topic, new HashSet<>(16));
}
for (QueueData qd : topicRouteData.getQueueDatas()) {
if (brokerNameSet.contains(qd.getBrokerName())) {
for (int i = 0; i < qd.getReadQueueNums(); i++) {
TaskTopicInfo taskTopicInfo = new TaskTopicInfo(topic, qd.getBrokerName(), i, null);
topicRouteMap.get(topic).add(taskTopicInfo);
}
}
}
}
} catch (Exception e) {
log.error("Fetch topic list error.", e);
} finally {
srcMQAdminExt.shutdown();
}
}
Aggregations