Caideyipi commented on code in PR #12355:
URL: https://github.com/apache/iotdb/pull/12355#discussion_r1609768685


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/task/CreatePipeProcedureV2.java:
##########
@@ -137,31 +144,49 @@ public void 
executeFromCalculateInfoForTask(ConfigNodeProcedureEnv env) {
     final ConcurrentMap<Integer, PipeTaskMeta> consensusGroupIdToTaskMetaMap =
         new ConcurrentHashMap<>();
 
-    // data regions & schema regions
-    env.getConfigManager()
-        .getLoadManager()
-        .getRegionLeaderMap()
-        .forEach(
-            (regionGroupId, regionLeaderNodeId) -> {
-              final String databaseName =
-                  
env.getConfigManager().getPartitionManager().getRegionStorageGroup(regionGroupId);
-              if (databaseName != null && 
!databaseName.equals(SchemaConstant.SYSTEM_DATABASE)) {
-                // Pipe only collect user's data, filter out metric database 
here.
-                consensusGroupIdToTaskMetaMap.put(
-                    regionGroupId.getId(),
-                    new PipeTaskMeta(MinimumProgressIndex.INSTANCE, 
regionLeaderNodeId));
-              }
-            });
-
-    // config region
-    consensusGroupIdToTaskMetaMap.put(
-        // 0 is the consensus group id of the config region, but data region 
id and schema region id
-        // also start from 0, so we use Integer.MIN_VALUE to represent the 
config region
-        Integer.MIN_VALUE,
-        new PipeTaskMeta(
-            MinimumProgressIndex.INSTANCE,
-            // The leader of the config region is the config node itself
-            ConfigNodeDescriptor.getInstance().getConf().getConfigNodeId()));
+    if (PipeType.CONSENSUS.equals(pipeStaticMeta.getPipeType())) {

Review Comment:
   BTW currently the "RouteBalancer" and the cached leaderIds are unadapted yet.



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/PipeConsensusConfig.java:
##########
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.consensus.config;
+
+import org.apache.iotdb.commons.client.property.ClientPoolProperty;
+import org.apache.iotdb.commons.pipe.plugin.builtin.BuiltinPipePlugin;
+import org.apache.iotdb.consensus.pipe.consensuspipe.ConsensusPipeDispatcher;
+import org.apache.iotdb.consensus.pipe.consensuspipe.ConsensusPipeGuardian;
+import org.apache.iotdb.consensus.pipe.consensuspipe.ConsensusPipeReceiver;
+import org.apache.iotdb.consensus.pipe.consensuspipe.ConsensusPipeSelector;
+import org.apache.iotdb.consensus.pipe.consensuspipe.ProgressIndexManager;
+
+import java.util.concurrent.TimeUnit;
+
+public class PipeConsensusConfig {
+  private final RPC rpc;
+  private final Pipe pipe;
+
+  public PipeConsensusConfig(RPC rpc, Pipe pipe) {
+    this.rpc = rpc;
+    this.pipe = pipe;
+  }
+
+  public RPC getRpc() {
+    return rpc;
+  }
+
+  public Pipe getPipe() {
+    return pipe;
+  }
+
+  public static Builder newBuilder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private RPC rpc;
+    private Pipe pipe;
+
+    public Builder setPipe(Pipe pipe) {
+      this.pipe = pipe;
+      return this;
+    }
+
+    public Builder setRPC(RPC rpc) {
+      this.rpc = rpc;
+      return this;
+    }
+
+    public PipeConsensusConfig build() {
+      return new PipeConsensusConfig(rpc, pipe);
+    }
+  }
+
+  public static class RPC {

Review Comment:
   The name of this may better be changed to "RpcConfig" and "PipeConfig"...



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/task/CreatePipeProcedureV2.java:
##########
@@ -137,31 +144,49 @@ public void 
executeFromCalculateInfoForTask(ConfigNodeProcedureEnv env) {
     final ConcurrentMap<Integer, PipeTaskMeta> consensusGroupIdToTaskMetaMap =
         new ConcurrentHashMap<>();
 
-    // data regions & schema regions
-    env.getConfigManager()
-        .getLoadManager()
-        .getRegionLeaderMap()
-        .forEach(
-            (regionGroupId, regionLeaderNodeId) -> {
-              final String databaseName =
-                  
env.getConfigManager().getPartitionManager().getRegionStorageGroup(regionGroupId);
-              if (databaseName != null && 
!databaseName.equals(SchemaConstant.SYSTEM_DATABASE)) {
-                // Pipe only collect user's data, filter out metric database 
here.
-                consensusGroupIdToTaskMetaMap.put(
-                    regionGroupId.getId(),
-                    new PipeTaskMeta(MinimumProgressIndex.INSTANCE, 
regionLeaderNodeId));
-              }
-            });
-
-    // config region
-    consensusGroupIdToTaskMetaMap.put(
-        // 0 is the consensus group id of the config region, but data region 
id and schema region id
-        // also start from 0, so we use Integer.MIN_VALUE to represent the 
config region
-        Integer.MIN_VALUE,
-        new PipeTaskMeta(
-            MinimumProgressIndex.INSTANCE,
-            // The leader of the config region is the config node itself
-            ConfigNodeDescriptor.getInstance().getConf().getConfigNodeId()));
+    if (PipeType.CONSENSUS.equals(pipeStaticMeta.getPipeType())) {

Review Comment:
   The pipes shall be created based on "sender-dn-id", not "region leader"....



-- 
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: reviews-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to