You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "VGalaxies (via GitHub)" <gi...@apache.org> on 2024/01/23 14:21:38 UTC
[PR] Pipe: support alter pipe functionality [iotdb]
VGalaxies opened a new pull request, #11963:
URL: https://github.com/apache/iotdb/pull/11963
## Description
As title, this PR introduces the Alter Pipe SQL statement for dynamically updating an existing Pipe's source, processor, and sink plugins. The general syntax is as follows:
```sql
alter pipe <pipe_name> with source (...) with processor (...) with sink (...)
```
NOTE:
1. Key-value pairs provided in the alter statement for source, processor, and sink will **override** the previous key-value pairs. For example, if `start-time` filtering parameters were specified when creating pipe but are not provided in alter pipe statement, the `start-time` parameter will not be present in the final configuration.
2. If the alter statement does not provide any configuration for a specific source, processor, or sink, the previous configuration will be **reused**.
3. The creation time will be updated to the time of the alter pipe operation.
---
Example:
```text
IoTDB> create pipe a2b with source ('pattern'='root.test.g_0') with sink ('node-urls'='127.0.0.1:6668')
Msg: The statement is executed successfully.
IoTDB> show pipes;
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
| ID| CreationTime| State| PipeSource|PipeProcessor| PipeSink|ExceptionMessage|
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
|a2b|2024-01-23T22:07:09.516|RUNNING|{pattern=root.test.g_0}| {}|{node-urls=127.0.0.1:6668}| |
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
Total line number = 1
It costs 0.133s
IoTDB> alter pipe a2b with source ('pattern'='root.test.g_1')
Msg: The statement is executed successfully.
IoTDB> show pipes;
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
| ID| CreationTime| State| PipeSource|PipeProcessor| PipeSink|ExceptionMessage|
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
|a2b|2024-01-23T22:07:12.926|RUNNING|{pattern=root.test.g_1}| {}|{node-urls=127.0.0.1:6668}| |
+---+-----------------------+-------+-----------------------+-------------+--------------------------+----------------+
Total line number = 1
It costs 0.006s
```
---
TODOs:
- [ ] IT
<!--
In each section, please describe design decisions made, including:
- Choice of algorithms
- Behavioral aspects. What configuration values are acceptable? How are corner cases and error
conditions handled, such as when there are insufficient resources?
- Class organization and design (how the logic is split between classes, inheritance, composition,
design patterns)
- Method organization and design (how the logic is split between methods, parameters and return types)
- Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
-->
<!-- It's good to describe an alternative design (or mention an alternative name) for every design
(or naming) decision point and compare the alternatives with the designs that you've implemented
(or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
<!-- If there was a discussion of the design of the feature implemented in this PR elsewhere
(e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list),
link to that discussion from this PR description and explain what have changed in your final design
compared to your original proposal or the consensus version in the end of the discussion.
If something hasn't changed since the original discussion, you can omit a detailed discussion of
those aspects of the design here, perhaps apart from brief mentioning for the sake of readability
of this PR description. -->
<!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
<hr>
This PR has:
- [x] been self-reviewed.
- [ ] concurrent read
- [ ] concurrent write
- [ ] concurrent read and write
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods.
- [ ] added or updated version, __license__, or notice information
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious
for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold
for code coverage.
- [ ] added integration tests.
- [x] been tested in a test IoTDB cluster.
<!-- Check the items by putting "x" in the brackets for the done things. Not all of these items
apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items
from the checklist above are strictly necessary, but it would be very helpful if you at least
self-review the PR. -->
<hr>
##### Key changed/added classes (or packages if there are too many classes) in this PR
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470947900
##########
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:
..
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470791857
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java:
##########
@@ -158,6 +162,61 @@ 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())) {
Review Comment:
fast failing here should be better
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470954954
##########
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 {
Review Comment:
In theory, we need to serialize all members, including alterPipeRequest, pipeStaticMeta, and pipeRuntimeMeta
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
Caideyipi commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470501885
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/pipe/task/AlterPipePlanV2.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.task;
+
+import org.apache.iotdb.commons.pipe.task.meta.PipeRuntimeMeta;
+import org.apache.iotdb.commons.pipe.task.meta.PipeStaticMeta;
+import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
+import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class AlterPipePlanV2 extends ConfigPhysicalPlan {
Review Comment:
Add a ser/de test in the "ConfigPhysicalPlanSerDeTest"
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470982135
##########
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));
Review Comment:
..
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11963:
URL: https://github.com/apache/iotdb/pull/11963#discussion_r1470799589
##########
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.CREATE_PIPE;
Review Comment:
```suggestion
return PipeTaskOperation.ALTER_PIPE;
```
--
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pipe: support alter pipe functionality [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
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-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org