You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "Caideyipi (via GitHub)" <gi...@apache.org> on 2024/01/28 11:51:09 UTC
[PR] Pipe: Support mod transfer in historical tsFiles [iotdb]
Caideyipi opened a new pull request, #11998:
URL: https://github.com/apache/iotdb/pull/11998
## Description
As the title said.
<!--
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:
- [ ] 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.
- [ ] 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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11998:
URL: https://github.com/apache/iotdb/pull/11998#discussion_r1540549708
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/ConfigRegionStateMachine.java:
##########
@@ -197,12 +198,33 @@ protected DataSet read(ConfigPhysicalPlan plan) {
@Override
public boolean takeSnapshot(File snapshotDir) {
- return executor.takeSnapshot(snapshotDir);
+ if (executor.takeSnapshot(snapshotDir)) {
+ try {
+ PipeConfigNodeAgent.runtime()
+ .listener()
+ .tryListenToSnapshots(ConfignodeSnapshotParser.getSnapshots());
+ return true;
+ } catch (IOException e) {
+ LOGGER.error(
+ "Config Region Listening Queue Listen to snapshot failed, the historical data may not be transferred.");
Review Comment:
```suggestion
LOGGER.error(
"Config Region Listening Queue Listen to snapshot failed, the historical data may not be transferred.", e);
```
--
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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11998:
URL: https://github.com/apache/iotdb/pull/11998#discussion_r1542416753
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/task/builder/PipeDataNodeBuilder.java:
##########
@@ -45,25 +48,36 @@ public PipeDataNodeBuilder(PipeMeta pipeMeta) {
this.pipeMeta = pipeMeta;
}
- public Map<Integer, PipeTask> build() {
+ public Map<Integer, PipeTask> build() throws IllegalPathException {
final PipeStaticMeta pipeStaticMeta = pipeMeta.getStaticMeta();
final PipeRuntimeMeta pipeRuntimeMeta = pipeMeta.getRuntimeMeta();
- final List<DataRegionId> dataRegionIds = StorageEngine.getInstance().getAllDataRegionIds();
- final List<SchemaRegionId> schemaRegionIds = SchemaEngine.getInstance().getAllSchemaRegionIds();
Review Comment:
Keep
--
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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu merged PR #11998:
URL: https://github.com/apache/iotdb/pull/11998
--
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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11998:
URL: https://github.com/apache/iotdb/pull/11998#discussion_r1542402774
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/ConfigRegionStateMachine.java:
##########
@@ -197,12 +198,34 @@ protected DataSet read(ConfigPhysicalPlan plan) {
@Override
public boolean takeSnapshot(File snapshotDir) {
- return executor.takeSnapshot(snapshotDir);
+ if (executor.takeSnapshot(snapshotDir)) {
+ try {
+ PipeConfigNodeAgent.runtime()
+ .listener()
+ .tryListenToSnapshots(ConfignodeSnapshotParser.getSnapshots());
+ return true;
+ } catch (IOException e) {
+ LOGGER.error(
+ "Config Region Listening Queue Listen to snapshot failed, the historical data may not be transferred.",
+ e);
+ }
+ }
+ return false;
}
@Override
public void loadSnapshot(File latestSnapshotRootDir) {
- executor.loadSnapshot(latestSnapshotRootDir);
+ try {
+ executor.loadSnapshot(latestSnapshotRootDir);
+ // We recompute the snapshot for pipe listener when loading snapshot
+ // to recover the newest snapshot in cache
+ PipeConfigNodeAgent.runtime()
+ .listener()
+ .tryListenToSnapshots(ConfignodeSnapshotParser.getSnapshots());
+ } catch (IOException e) {
+ LOGGER.error(
+ "Config Region Listening Queue Listen to snapshot failed when startup, snapshot will be tried again when starting schema transferring pipes");
Review Comment:
```suggestion
LOGGER.error(
"Config Region Listening Queue Listen to snapshot failed when startup, snapshot will be tried again when starting schema transferring pipes", e);
```
--
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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11998:
URL: https://github.com/apache/iotdb/pull/11998#discussion_r1540583001
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/traverser/Traverser.java:
##########
@@ -155,17 +156,17 @@ private N getChild(N parent, String childName, boolean skipTemplateChildren)
} else {
if (templateMap != null
&& !skipTemplateChildren
- && !templateMap.isEmpty() // this task will cover some timeseries represented by template
+ && !templateMap.isEmpty() // Rhis task will cover some timeseries represented by template
&& (parent.isDevice()
&& parent.getAsDeviceMNode().getSchemaTemplateId()
- != NON_TEMPLATE) // the device is using template
+ != NON_TEMPLATE) // Rhe device is using template
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 mod transfer in pipe tsFiles & schema region snapshot transferring logic [iotdb]
Posted by "SteveYurongSu (via GitHub)" <gi...@apache.org>.
SteveYurongSu commented on code in PR #11998:
URL: https://github.com/apache/iotdb/pull/11998#discussion_r1542641170
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/payload/thrift/request/PipeTransferFileSealReqV2.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.commons.pipe.connector.payload.thrift.request;
+
+import org.apache.iotdb.service.rpc.thrift.TPipeTransferReq;
+import org.apache.iotdb.tsfile.utils.PublicBAOS;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public abstract class PipeTransferFileSealReqV2 extends TPipeTransferReq {
+
+ private transient List<String> fileNames;
+ private transient List<Long> fileLengths;
+ private transient Map<String, String> parameters;
+
+ public final List<String> getFileNames() {
+ return fileNames;
+ }
+
+ public final List<Long> getFileLengths() {
+ return fileLengths;
+ }
+
+ public final Map<String, String> getParameters() {
+ return parameters;
+ }
+
+ protected abstract PipeRequestType getPlanType();
+
+ /////////////////////////////// Thrift ///////////////////////////////
+
+ protected PipeTransferFileSealReqV2 convertToTPipeTransferReq(
+ List<String> fileNames, List<Long> fileLengths, Map<String, String> parameters)
+ throws IOException {
+
+ this.fileNames = fileNames;
+ this.fileLengths = fileLengths;
+ this.parameters = parameters;
+
+ this.version = IoTDBConnectorRequestVersion.VERSION_1.getVersion();
+ this.type = getPlanType().getType();
+ try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
+ final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
+ ReadWriteIOUtils.write(fileNames.size(), outputStream);
+ for (String fileName : fileNames) {
+ ReadWriteIOUtils.write(fileName, outputStream);
+ }
+ ReadWriteIOUtils.write(fileLengths.size(), outputStream);
+ for (Long fileLength : fileLengths) {
+ ReadWriteIOUtils.write(fileLength, outputStream);
+ }
+ ReadWriteIOUtils.write(parameters.size(), outputStream);
+ for (final Map.Entry<String, String> entry : parameters.entrySet()) {
+ ReadWriteIOUtils.write(entry.getKey(), outputStream);
+ ReadWriteIOUtils.write(entry.getValue(), outputStream);
+ }
+ this.body = ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size());
+ }
+
+ return this;
+ }
+
+ public PipeTransferFileSealReqV2 translateFromTPipeTransferReq(TPipeTransferReq req) {
+ fileNames = new ArrayList<>();
+ int size = ReadWriteIOUtils.readInt(req.body);
+ for (int i = 0; i < size; ++i) {
+ fileNames.add(ReadWriteIOUtils.readString(req.body));
+ }
+
+ fileLengths = new ArrayList<>();
+ size = ReadWriteIOUtils.readInt(req.body);
+ for (int i = 0; i < size; ++i) {
+ fileLengths.add(ReadWriteIOUtils.readLong(req.body));
+ }
+
+ parameters = new HashMap<>();
+ size = ReadWriteIOUtils.readInt(req.body);
+ for (int i = 0; i < size; ++i) {
+ final String key = ReadWriteIOUtils.readString(req.body);
+ final String value = ReadWriteIOUtils.readString(req.body);
+ parameters.put(key, value);
+ }
+
+ version = req.version;
+ type = req.type;
+ body = req.body;
+
+ return this;
+ }
+
+ /////////////////////////////// Air Gap ///////////////////////////////
+
+ public byte[] convertToTPipeTransferSnapshotSealBytes(
+ List<String> fileNames, List<Long> fileLengths, Map<String, String> parameters)
+ throws IOException {
+ try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
+ final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
+ ReadWriteIOUtils.write(IoTDBConnectorRequestVersion.VERSION_1.getVersion(), outputStream);
+ ReadWriteIOUtils.write(getPlanType().getType(), outputStream);
+ ReadWriteIOUtils.write(fileNames.size(), outputStream);
+ for (String fileName : fileNames) {
+ ReadWriteIOUtils.write(fileName, outputStream);
+ }
+ ReadWriteIOUtils.write(fileLengths.size(), outputStream);
+ for (Long fileLength : fileLengths) {
+ ReadWriteIOUtils.write(fileLength, outputStream);
+ }
+ ReadWriteIOUtils.write(parameters.size(), outputStream);
+ for (final Map.Entry<String, String> entry : parameters.entrySet()) {
+ ReadWriteIOUtils.write(entry.getKey(), outputStream);
+ ReadWriteIOUtils.write(entry.getValue(), outputStream);
+ }
+ return byteArrayOutputStream.toByteArray();
+ }
+ }
+
+ /////////////////////////////// Object ///////////////////////////////
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ PipeTransferFileSealReqV2 that = (PipeTransferFileSealReqV2) obj;
+ return fileNames.equals(that.fileNames)
+ && fileLengths.equals(that.fileLengths)
+ && parameters.equals(that.parameters)
+ && version == that.version
+ && type == that.type
+ && body.equals(that.body);
Review Comment:
NPE
--
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