SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470996152


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/task/AlterPipeProcedureV2.java:
##########
@@ -0,0 +1,299 @@
+/*
+ * 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.confignode.procedure.impl.pipe.task;
+
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.consensus.index.impl.MinimumProgressIndex;
+import org.apache.iotdb.commons.pipe.task.meta.PipeRuntimeMeta;
+import org.apache.iotdb.commons.pipe.task.meta.PipeStaticMeta;
+import org.apache.iotdb.commons.pipe.task.meta.PipeStatus;
+import org.apache.iotdb.commons.pipe.task.meta.PipeTaskMeta;
+import org.apache.iotdb.commons.schema.SchemaConstant;
+import 
org.apache.iotdb.confignode.consensus.request.write.pipe.task.AlterPipePlanV2;
+import 
org.apache.iotdb.confignode.consensus.request.write.pipe.task.DropPipePlanV2;
+import org.apache.iotdb.confignode.manager.pipe.coordinator.PipeManager;
+import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv;
+import 
org.apache.iotdb.confignode.procedure.impl.pipe.AbstractOperatePipeProcedureV2;
+import org.apache.iotdb.confignode.procedure.impl.pipe.PipeTaskOperation;
+import org.apache.iotdb.confignode.procedure.store.ProcedureType;
+import org.apache.iotdb.confignode.rpc.thrift.TAlterPipeReq;
+import org.apache.iotdb.consensus.exception.ConsensusException;
+import org.apache.iotdb.pipe.api.exception.PipeException;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class AlterPipeProcedureV2 extends AbstractOperatePipeProcedureV2 {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(AlterPipeProcedureV2.class);
+
+  private TAlterPipeReq alterPipeRequest;
+
+  private PipeStaticMeta pipeStaticMeta;
+  private PipeRuntimeMeta pipeRuntimeMeta;
+
+  public AlterPipeProcedureV2() {
+    super();
+  }
+
+  public AlterPipeProcedureV2(TAlterPipeReq alterPipeRequest) throws 
PipeException {
+    super();
+    this.alterPipeRequest = alterPipeRequest;
+  }
+
+  @Override
+  protected PipeTaskOperation getOperation() {
+    return PipeTaskOperation.ALTER_PIPE;
+  }
+
+  @Override
+  protected boolean executeFromValidateTask(ConfigNodeProcedureEnv env) throws 
PipeException {
+    LOGGER.info(
+        "AlterPipeProcedureV2: executeFromValidateTask({})", 
alterPipeRequest.getPipeName());
+
+    final PipeManager pipeManager = env.getConfigManager().getPipeManager();
+    pipeManager
+        .getPipePluginCoordinator()
+        .getPipePluginInfo()
+        .checkPipePluginExistence(
+            alterPipeRequest.getExtractorAttributes(),
+            alterPipeRequest.getProcessorAttributes(),
+            alterPipeRequest.getConnectorAttributes());
+    pipeTaskInfo.get().checkBeforeAlterPipe(alterPipeRequest);
+
+    return false;
+  }
+
+  @Override
+  protected void executeFromCalculateInfoForTask(ConfigNodeProcedureEnv env) {
+    LOGGER.info(
+        "AlterPipeProcedureV2: executeFromCalculateInfoForTask({})",
+        alterPipeRequest.getPipeName());
+
+    pipeStaticMeta =
+        new PipeStaticMeta(
+            alterPipeRequest.getPipeName(),
+            System.currentTimeMillis(),
+            alterPipeRequest.getExtractorAttributes(),
+            alterPipeRequest.getProcessorAttributes(),
+            alterPipeRequest.getConnectorAttributes());
+
+    final Map<TConsensusGroupId, PipeTaskMeta> consensusGroupIdToTaskMetaMap = 
new HashMap<>();
+    env.getConfigManager()
+        .getLoadManager()
+        .getRegionLeaderMap()
+        .forEach(
+            (regionGroupId, regionLeaderNodeId) -> {
+              if 
(regionGroupId.getType().equals(TConsensusGroupType.DataRegion)) {
+                final String databaseName =
+                    env.getConfigManager()
+                        .getPartitionManager()
+                        .getRegionStorageGroup(regionGroupId);
+                if (databaseName != null && 
!databaseName.equals(SchemaConstant.SYSTEM_DATABASE)) {
+                  // Pipe only collect user's data, filter metric database 
here.
+                  consensusGroupIdToTaskMetaMap.put(
+                      regionGroupId,
+                      new PipeTaskMeta(MinimumProgressIndex.INSTANCE, 
regionLeaderNodeId));
+                }
+              }
+            });
+    pipeRuntimeMeta = new PipeRuntimeMeta(consensusGroupIdToTaskMetaMap);
+    pipeRuntimeMeta.getStatus().set(PipeStatus.RUNNING);

Review Comment:
   USER STOPPED



-- 
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