Caideyipi commented on code in PR #11963: URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470885629
########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/AbstractOperatePipeProcedureV2.java: ########## @@ -50,9 +50,9 @@ import java.util.concurrent.atomic.AtomicReference; /** - * This procedure manages 4 kinds of PIPE operations: {@link PipeTaskOperation#CREATE_PIPE}, {@link - * PipeTaskOperation#START_PIPE}, {@link PipeTaskOperation#STOP_PIPE} and {@link - * PipeTaskOperation#DROP_PIPE}. + * This procedure manages 5 kinds of PIPE operations: {@link PipeTaskOperation#CREATE_PIPE}, {@link + * PipeTaskOperation#START_PIPE}, {@link PipeTaskOperation#STOP_PIPE}, {@link + * PipeTaskOperation#DROP_PIPE} and {@link PipeTaskOperation#ALTER_PIPE}. Review Comment: Maybe separately explain user operation like "CREATE PIPE" and runtime operation like "SYNC_PIPE_META" is better. ########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java: ########## @@ -158,6 +162,60 @@ private void checkBeforeCreatePipeInternal(TCreatePipeReq createPipeRequest) throw new PipeException(exceptionMessage); } + public void checkBeforeAlterPipe(TAlterPipeReq alterPipeRequest) throws PipeException { + acquireReadLock(); + try { + checkBeforeAlterPipeInternal(alterPipeRequest); + } finally { + releaseReadLock(); + } + } + + private void checkBeforeAlterPipeInternal(TAlterPipeReq alterPipeRequest) throws PipeException { + if (!isPipeExisted(alterPipeRequest.getPipeName())) { + final String exceptionMessage = + String.format( + "Failed to alter pipe %s, the pipe does not exist", alterPipeRequest.getPipeName()); + LOGGER.info(exceptionMessage); + throw new PipeException(exceptionMessage); + } + + PipeMeta pipeMetaFromCoordinator = getPipeMetaByPipeName(alterPipeRequest.getPipeName()); + PipeStaticMeta pipeStaticMetaFromCoordinator = pipeMetaFromCoordinator.getStaticMeta(); + // check unexpected pipe source plugin alter + if (!(new TreeMap<>(pipeStaticMetaFromCoordinator.getExtractorParameters().getAttribute()) + .toString()) + .equals(new TreeMap<>(alterPipeRequest.getExtractorAttributes()).toString())) { + final String exceptionMessage = + String.format( + "Failed to alter pipe %s, unexpected pipe source plugin alter, source plugin from CN: %s, source plugin from DN: %s", Review Comment: This error message can be slightly clearer ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java: ########## @@ -1655,6 +1660,91 @@ public SettableFuture<ConfigTaskResult> createPipe(CreatePipeStatement createPip return future; } + @Override + public SettableFuture<ConfigTaskResult> alterPipe(AlterPipeStatement alterPipeStatement) { + SettableFuture<ConfigTaskResult> future = SettableFuture.create(); + + // Get pipe static meta + final String pipeName = alterPipeStatement.getPipeName(); + final PipeStaticMeta pipeStaticMeta = PipeAgent.task().getPipeStaticMeta(pipeName); + if (Objects.isNull(pipeStaticMeta)) { + future.setException( + new IoTDBException( + String.format("Failed to alter pipe %s, the pipe does not exist", pipeName), + TSStatusCode.PIPE_ERROR.getStatusCode())); + return future; + } + + // We do not support alter source plugin of pipe, so the previous configuration will be reused. + alterPipeStatement.setExtractorAttributes( Review Comment: I suggest pass the order directly to configNode here without checking logic other than the checks in PipePluginAgent. ########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java: ########## @@ -283,6 +341,19 @@ public TSStatus createPipe(CreatePipePlanV2 plan) { } } + public TSStatus alterPipe(AlterPipePlanV2 plan) { + acquireWriteLock(); + try { + pipeMetaKeeper.removePipeMeta(plan.getPipeStaticMeta().getPipeName()); + pipeMetaKeeper.addPipeMeta( + plan.getPipeStaticMeta().getPipeName(), + new PipeMeta(plan.getPipeStaticMeta(), plan.getPipeRuntimeMeta())); Review Comment: I strongly suggest that updating progressIndex also here... What about DNs are crushed? Then they restart and fetch only a MinimumProgressIndex at configNode... ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java: ########## @@ -1655,6 +1660,91 @@ public SettableFuture<ConfigTaskResult> createPipe(CreatePipeStatement createPip return future; } + @Override + public SettableFuture<ConfigTaskResult> alterPipe(AlterPipeStatement alterPipeStatement) { + SettableFuture<ConfigTaskResult> future = SettableFuture.create(); + + // Get pipe static meta + final String pipeName = alterPipeStatement.getPipeName(); + final PipeStaticMeta pipeStaticMeta = PipeAgent.task().getPipeStaticMeta(pipeName); Review Comment: The pipeTaskAgent may not know this... Like when previous synchronizations are failed due to a dead address at connector: Consider this, a "createPipe" successfully handshakes with the receiver before configNode knows it, but the receiver is crushed just before the "CreatePipeProcedureV2" push the pipeMeta to dataNode. In this circumstance, the pipeTaskAgent does not know this pipe. You should allow users to alter a pipe like this that can not be created, and consequently won't be recorded at pipeTaskAgent. ########## 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); + } + + @Override + protected void executeFromWriteConfigNodeConsensus(ConfigNodeProcedureEnv env) + throws PipeException { + LOGGER.info( + "AlterPipeProcedureV2: executeFromWriteConfigNodeConsensus({})", + alterPipeRequest.getPipeName()); + + TSStatus response; + try { + response = + env.getConfigManager() + .getConsensusManager() + .write(new AlterPipePlanV2(pipeStaticMeta, pipeRuntimeMeta)); + } catch (ConsensusException e) { + LOGGER.warn("Failed in the write API executing the consensus layer due to: ", e); + response = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode()); + response.setMessage(e.getMessage()); + } + if (response.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + throw new PipeException(response.getMessage()); + } + } + + @Override + protected void executeFromOperateOnDataNodes(ConfigNodeProcedureEnv env) throws IOException { + final String pipeName = alterPipeRequest.getPipeName(); + LOGGER.info("AlterPipeProcedureV2: executeFromOperateOnDataNodes({})", pipeName); + + String exceptionMessage = + parsePushPipeMetaExceptionForPipe(pipeName, pushSinglePipeMetaToDataNodes(pipeName, env)); + if (!exceptionMessage.isEmpty()) { + LOGGER.warn( + "Failed to alter pipe {}, details: {}, metadata will be synchronized later.", + alterPipeRequest.getPipeName(), + exceptionMessage); + } + } + + @Override + protected void rollbackFromValidateTask(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromValidateTask({})", alterPipeRequest.getPipeName()); + // Do nothing + } + + @Override + protected void rollbackFromCalculateInfoForTask(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromCalculateInfoForTask({})", + alterPipeRequest.getPipeName()); + // Do nothing + } + + @Override + protected void rollbackFromWriteConfigNodeConsensus(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromWriteConfigNodeConsensus({})", + alterPipeRequest.getPipeName()); + TSStatus response; + try { + response = + env.getConfigManager() + .getConsensusManager() + .write(new DropPipePlanV2(alterPipeRequest.getPipeName())); Review Comment: Is it OK to drop pipe when rolling back on configNode? ########## iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java: ########## @@ -1110,7 +1111,7 @@ public void CreatePipePlanV2Test() throws IOException { Map<String, String> connectorAttributes = new HashMap<>(); extractorAttributes.put("extractor", "org.apache.iotdb.pipe.extractor.DefaultExtractor"); processorAttributes.put("processor", "org.apache.iotdb.pipe.processor.SDTFilterProcessor"); - connectorAttributes.put("connector", "org.apache.iotdb.pipe.protocal.ThriftTransporter"); + connectorAttributes.put("connector", "org.apache.iotdb.pipe.protocol.ThriftTransporter"); Review Comment: Can incidentally update the plugin names ########## 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); + } + + @Override + protected void executeFromWriteConfigNodeConsensus(ConfigNodeProcedureEnv env) + throws PipeException { + LOGGER.info( + "AlterPipeProcedureV2: executeFromWriteConfigNodeConsensus({})", + alterPipeRequest.getPipeName()); + + TSStatus response; + try { + response = + env.getConfigManager() + .getConsensusManager() + .write(new AlterPipePlanV2(pipeStaticMeta, pipeRuntimeMeta)); + } catch (ConsensusException e) { + LOGGER.warn("Failed in the write API executing the consensus layer due to: ", e); + response = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode()); + response.setMessage(e.getMessage()); + } + if (response.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + throw new PipeException(response.getMessage()); + } + } + + @Override + protected void executeFromOperateOnDataNodes(ConfigNodeProcedureEnv env) throws IOException { + final String pipeName = alterPipeRequest.getPipeName(); + LOGGER.info("AlterPipeProcedureV2: executeFromOperateOnDataNodes({})", pipeName); + + String exceptionMessage = + parsePushPipeMetaExceptionForPipe(pipeName, pushSinglePipeMetaToDataNodes(pipeName, env)); + if (!exceptionMessage.isEmpty()) { + LOGGER.warn( + "Failed to alter pipe {}, details: {}, metadata will be synchronized later.", + alterPipeRequest.getPipeName(), + exceptionMessage); + } + } + + @Override + protected void rollbackFromValidateTask(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromValidateTask({})", alterPipeRequest.getPipeName()); + // Do nothing + } + + @Override + protected void rollbackFromCalculateInfoForTask(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromCalculateInfoForTask({})", + alterPipeRequest.getPipeName()); + // Do nothing + } + + @Override + protected void rollbackFromWriteConfigNodeConsensus(ConfigNodeProcedureEnv env) { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromWriteConfigNodeConsensus({})", + alterPipeRequest.getPipeName()); + TSStatus response; + try { + response = + env.getConfigManager() + .getConsensusManager() + .write(new DropPipePlanV2(alterPipeRequest.getPipeName())); + } catch (ConsensusException e) { + LOGGER.warn("Failed in the write API executing the consensus layer due to: ", e); + response = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode()); + response.setMessage(e.getMessage()); + } + if (response.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + throw new PipeException(response.getMessage()); + } + } + + @Override + protected void rollbackFromOperateOnDataNodes(ConfigNodeProcedureEnv env) throws IOException { + LOGGER.info( + "AlterPipeProcedureV2: rollbackFromOperateOnDataNodes({})", alterPipeRequest.getPipeName()); + + // Push all pipe metas to datanode, may be time-consuming + String exceptionMessage = + parsePushPipeMetaExceptionForPipe( + alterPipeRequest.getPipeName(), pushPipeMetaToDataNodes(env)); + if (!exceptionMessage.isEmpty()) { + LOGGER.warn( + "Failed to rollback alter pipe {}, details: {}, metadata will be synchronized later.", + alterPipeRequest.getPipeName(), + exceptionMessage); + } + } + + @Override + public void serialize(DataOutputStream stream) throws IOException { + stream.writeShort(ProcedureType.ALTER_PIPE_PROCEDURE_V2.getTypeCode()); + super.serialize(stream); + ReadWriteIOUtils.write(alterPipeRequest.getPipeName(), stream); + ReadWriteIOUtils.write(alterPipeRequest.getExtractorAttributesSize(), stream); + for (Map.Entry<String, String> entry : alterPipeRequest.getExtractorAttributes().entrySet()) { + ReadWriteIOUtils.write(entry.getKey(), stream); + ReadWriteIOUtils.write(entry.getValue(), stream); + } + ReadWriteIOUtils.write(alterPipeRequest.getProcessorAttributesSize(), stream); + for (Map.Entry<String, String> entry : alterPipeRequest.getProcessorAttributes().entrySet()) { + ReadWriteIOUtils.write(entry.getKey(), stream); + ReadWriteIOUtils.write(entry.getValue(), stream); + } + ReadWriteIOUtils.write(alterPipeRequest.getConnectorAttributesSize(), stream); + for (Map.Entry<String, String> entry : alterPipeRequest.getConnectorAttributes().entrySet()) { + ReadWriteIOUtils.write(entry.getKey(), stream); + ReadWriteIOUtils.write(entry.getValue(), stream); + } + if (pipeStaticMeta != null) { + ReadWriteIOUtils.write(true, stream); + pipeStaticMeta.serialize(stream); + } else { + ReadWriteIOUtils.write(false, stream); + } + } + + @Override + public void deserialize(ByteBuffer byteBuffer) { + super.deserialize(byteBuffer); + alterPipeRequest = + new TAlterPipeReq() + .setPipeName(ReadWriteIOUtils.readString(byteBuffer)) + .setExtractorAttributes(new HashMap<>()) + .setProcessorAttributes(new HashMap<>()) + .setConnectorAttributes(new HashMap<>()); + int size = ReadWriteIOUtils.readInt(byteBuffer); + for (int i = 0; i < size; ++i) { + alterPipeRequest + .getExtractorAttributes() + .put(ReadWriteIOUtils.readString(byteBuffer), ReadWriteIOUtils.readString(byteBuffer)); + } + size = ReadWriteIOUtils.readInt(byteBuffer); + for (int i = 0; i < size; ++i) { + alterPipeRequest + .getProcessorAttributes() + .put(ReadWriteIOUtils.readString(byteBuffer), ReadWriteIOUtils.readString(byteBuffer)); + } + size = ReadWriteIOUtils.readInt(byteBuffer); + for (int i = 0; i < size; ++i) { + alterPipeRequest + .getConnectorAttributes() + .put(ReadWriteIOUtils.readString(byteBuffer), ReadWriteIOUtils.readString(byteBuffer)); + } + if (ReadWriteIOUtils.readBool(byteBuffer)) { + pipeStaticMeta = PipeStaticMeta.deserialize(byteBuffer); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AlterPipeProcedureV2 that = (AlterPipeProcedureV2) o; + return alterPipeRequest.getPipeName().equals(that.alterPipeRequest.getPipeName()); Review Comment: Maybe there is something more than pipe name to compare... -- 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