Caideyipi commented on code in PR #15112: URL: https://github.com/apache/iotdb/pull/15112#discussion_r2046452609
########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/pipe/payload/PipeEnrichedPlanV2.java: ########## @@ -0,0 +1,84 @@ +/* + * 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.consensus.request.write.pipe.payload; + +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType; + +import org.apache.tsfile.utils.ReadWriteIOUtils; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Objects; + +public class PipeEnrichedPlanV2 extends PipeEnrichedPlanV1 { + + private String originClusterId; + + public PipeEnrichedPlanV2() { + super(ConfigPhysicalPlanType.PipeEnrichedV2); + } + + public PipeEnrichedPlanV2(ConfigPhysicalPlan innerPlan, String originClusterId) { + super(ConfigPhysicalPlanType.PipeEnrichedV2); + this.innerPlan = innerPlan; + this.originClusterId = originClusterId; + } + + public String getOriginClusterId() { + return originClusterId; + } + + @Override + protected void serializeImpl(DataOutputStream stream) throws IOException { + super.serializeImpl(stream); + ReadWriteIOUtils.write(originClusterId, stream); + } + + @Override + protected void deserializeImpl(ByteBuffer buffer) throws IOException { + super.deserializeImpl(buffer); + originClusterId = ReadWriteIOUtils.readString(buffer); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + PipeEnrichedPlanV2 that = (PipeEnrichedPlanV2) obj; + return innerPlan.equals(that.innerPlan) + && Objects.equals(originClusterId, that.originClusterId); + } + + @Override + public int hashCode() { + return Objects.hash(innerPlan, originClusterId); + } + + @Override + public String toString() { + return "PipeEnrichedPlanV2{" + "innerPlan='" + innerPlan + "'}"; Review Comment: Better add "originClusterId" here ########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java: ########## @@ -87,6 +87,19 @@ public AuthOperationProcedure( this.timeoutMS = commonConfig.getDatanodeTokenTimeoutMS(); } Review Comment: May remove the unused constructors... Same in other files ########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/event/PipeConfigRegionWritePlanEvent.java: ########## @@ -91,23 +110,42 @@ public EnrichedEvent shallowCopySelfAndBindPipeTaskMetaForProgressReport( tablePattern, userName, skipIfNoPrivileges, - false); + false, + null); } @Override public ByteBuffer serializeToByteBuffer() { final ByteBuffer planBuffer = configPhysicalPlan.serializeToByteBuffer(); - final ByteBuffer result = ByteBuffer.allocate(Byte.BYTES * 2 + planBuffer.limit()); + final ByteBuffer result = + ByteBuffer.allocate( + Byte.BYTES * 2 + + planBuffer.limit() + + computeOriginClusterIdBufferSize(originClusterId)); ReadWriteIOUtils.write(PipeConfigSerializableEventType.CONFIG_WRITE_PLAN.getType(), result); ReadWriteIOUtils.write(isGeneratedByPipe, result); result.put(planBuffer); + ReadWriteIOUtils.write(originClusterId, result); return result; } @Override public void deserializeFromByteBuffer(final ByteBuffer buffer) throws IOException { isGeneratedByPipe = ReadWriteIOUtils.readBool(buffer); configPhysicalPlan = ConfigPhysicalPlan.Factory.create(buffer); + + // There might be an ignoredChildrenSize 0 Review Comment: The size may not appear on configNodes... ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java: ########## @@ -1045,6 +1045,7 @@ private RegionExecutionResult executeCreateOrUpdateTableDevice( @Override public RegionExecutionResult visitPipeEnrichedWritePlanNode( final PipeEnrichedWritePlanNode node, final WritePlanNodeExecutionContext context) { + node.setOriginClusterId(node.getOriginClusterId()); Review Comment: ...? ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/IoTDBDataRegionExtractor.java: ########## @@ -697,6 +698,14 @@ public void close() throws Exception { } } + public Set<String> getSinkClusterIds() { Review Comment: Is it used? ########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java: ########## @@ -59,7 +59,8 @@ public PermissionManager(ConfigManager configManager, AuthorInfo authorInfo) { * @param isGeneratedByPipe whether the plan is operated by pipe receiver * @return TSStatus */ - public TSStatus operatePermission(AuthorPlan authorPlan, boolean isGeneratedByPipe) { + public TSStatus operatePermission( + AuthorPlan authorPlan, boolean isGeneratedByPipe, String originClusterIds) { Review Comment: originClusterId<s> ########## iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java: ########## @@ -1668,16 +1669,17 @@ public void updateClusterIdPlanTest() throws IOException { @Test public void pipeEnrichedPlanTest() throws IOException { - final PipeEnrichedPlan plan = - new PipeEnrichedPlan( + final PipeEnrichedPlanV1 plan = Review Comment: Better use "V2".. Same in other tests ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/IoTDBDataRegionExtractor.java: ########## @@ -697,6 +698,14 @@ public void close() throws Exception { } } + public Set<String> getSinkClusterIds() { + return realtimeExtractor.getSinkClusterIds(); + } + + public void setSinkClusterIds(Set<String> sinkClusterIds) { + realtimeExtractor.setSinkClusterIds(sinkClusterIds); Review Comment: Personally I think it's better to put this in IoTDBExtractor... ########## iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift: ########## @@ -436,12 +437,14 @@ struct TDeleteDataForDeleteSchemaReq { 1: required list<common.TConsensusGroupId> dataRegionIdList 2: required binary pathPatternTree 3: optional bool isGeneratedByPipe + 4: optional string originClusterId } struct TDeleteTimeSeriesReq { 1: required list<common.TConsensusGroupId> schemaRegionIdList 2: required binary pathPatternTree 3: optional bool isGeneratedByPipe + 4: optional string originCluster Review Comment: Better add "Id" here ########## iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift: ########## @@ -497,6 +497,7 @@ struct TPipeTransferReq { struct TPipeTransferResp { 1:required common.TSStatus status 2:optional binary body + 3:optional string clusterId Review Comment: Better use "body" instead of adding a new field? -- 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]
