SteveYurongSu commented on code in PR #12138:
URL: https://github.com/apache/iotdb/pull/12138#discussion_r1531596306
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/task/subtask/connector/PipeConnectorSubtaskManager.java:
##########
@@ -117,26 +132,58 @@ public synchronized String register(
}
// 2. Construct PipeConnectorSubtaskLifeCycle to manage
PipeConnectorSubtask's life cycle
- final PipeConnectorSubtask pipeConnectorSubtask =
- new PipeConnectorSubtask(
+ if (!isSubscriptionConnector) {
+ final PipeConnectorSubtask pipeConnectorSubtask =
+ new PipeConnectorSubtask(
+ String.format(
+ "%s_%s_%s",
+ attributeSortedString, environment.getCreationTime(),
connectorIndex),
+ environment.getCreationTime(),
+ attributeSortedString,
+ connectorIndex,
+ pendingQueue,
+ pipeConnector);
+ final PipeConnectorSubtaskLifeCycle pipeConnectorSubtaskLifeCycle =
+ new PipeConnectorSubtaskLifeCycle(executor,
pipeConnectorSubtask, pendingQueue);
+ pipeConnectorSubtaskLifeCycleList.add(pipeConnectorSubtaskLifeCycle);
+ } else {
+ final String topicName =
+
pipeConnectorParameters.getString(PipeConnectorConstant.SINK_TOPIC_KEY);
+ final String consumerGroupId =
+
pipeConnectorParameters.getString(PipeConnectorConstant.SINK_CONSUMER_GROUP_KEY);
+ if (Objects.isNull(topicName) || Objects.isNull(consumerGroupId)) {
+ throw new SubscriptionException(
String.format(
- "%s_%s_%s",
- attributeSortedString, environment.getCreationTime(),
connectorIndex),
- environment.getCreationTime(),
- attributeSortedString,
- connectorIndex,
- pendingQueue,
- pipeConnector);
- final PipeConnectorSubtaskLifeCycle pipeConnectorSubtaskLifeCycle =
- new PipeConnectorSubtaskLifeCycle(executor, pipeConnectorSubtask,
pendingQueue);
- pipeConnectorSubtaskLifeCycleList.add(pipeConnectorSubtaskLifeCycle);
+ "Failed to construct subscription connector, because of %s
or %s does not exist in pipe connector parameters",
+ PipeConnectorConstant.SINK_TOPIC_KEY,
+ PipeConnectorConstant.SINK_CONSUMER_GROUP_KEY));
+ }
+ final SubscriptionConnectorSubtask subtask =
+ new SubscriptionConnectorSubtask(
+ String.format(
+ "%s_%s_%s",
+ attributeSortedString, environment.getCreationTime(),
connectorIndex),
+ environment.getCreationTime(),
+ attributeSortedString,
+ connectorIndex,
+ pendingQueue,
+ pipeConnector,
+ topicName,
+ consumerGroupId);
+ final PipeAbstractConnectorSubtaskLifeCycle
pipeConnectorSubtaskLifeCycle =
+ new SubscriptionConnectorSubtaskLifeCycle(
+
PipeSubtaskExecutorManager.getInstance().getSubscriptionExecutor(),
+ subtask,
+ pendingQueue);
Review Comment:
Need to be refactored.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]