You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/22 13:54:52 UTC

[GitHub] [iotdb] Cpaulyz commented on a diff in pull request #5804: [IOTDB-3102] data-sync support ext pipe fwk

Cpaulyz commented on code in PR #5804:
URL: https://github.com/apache/iotdb/pull/5804#discussion_r867668446


##########
external-pipe-api/src/main/java/org/apache/iotdb/pipe/external/api/IExternalPipeSinkWriter.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.pipe.external.api;
+
+import java.io.IOException;
+
+/** Responsible for forwarding the operations to the sink. */
+public interface IExternalPipeSinkWriter extends AutoCloseable {
+
+  /** Initialize the writer. */
+  void open() throws IOException;
+
+  /**
+   * Insert a boolean data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertBoolean(String[] path, long time, boolean value) throws IOException;
+
+  /**
+   * Insert a 32-bit integer data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertInt32(String[] path, long time, int value) throws IOException;
+
+  /**
+   * Insert a 64-bit integer data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertInt64(String[] path, long time, long value) throws IOException;
+
+  /**
+   * Insert a float data point to the sink.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertFloat(String[] path, long time, float value) throws IOException;
+
+  /**
+   * Insert a double data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertDouble(String[] path, long time, double value) throws IOException;
+
+  /**
+   * Insert a text data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param time Timestamp of the data point.
+   * @param value Value of the data point.
+   */
+  void insertText(String[] path, long time, String value) throws IOException;
+
+  /**
+   * Insert a vector data point to the sink.
+   *
+   * <p>The framework will retry if this method throws an {@link IOException}.
+   *
+   * @param path The parts of a path separated by '.'. For example, for a path root.a.b.c, the input
+   *     argument would be ["root", "a", "b", "c"].
+   * @param dataTypes Datatype of each element in the vector.
+   * @param time Timestamp of the data point.
+   * @param values Value of each element in the vector.
+   */
+  void insertVector(String[] path, DataType[] dataTypes, long time, Object[] values)

Review Comment:
   Param "path" indicates the path to the device to be written to. But how to indicate the measurements?



##########
server/src/main/java/org/apache/iotdb/db/sync/sender/service/SenderService.java:
##########
@@ -163,24 +173,29 @@ public synchronized void addPipe(CreatePipePlan plan) throws PipeException {
 
     PipeSink runningPipeSink = getPipeSink(plan.getPipeSinkName());
     runningPipe = parseCreatePipePlan(plan, runningPipeSink, currentTime);
-    try {
-      transportHandler =
-          TransportHandler.getNewTransportHandler(runningPipe, (IoTDBPipeSink) runningPipeSink);
-      sendMsg(RequestType.CREATE);
-    } catch (ClassCastException e) {
-      logger.error(
-          String.format(
-              "Cast Class to %s error when create pipe %s.",
-              IoTDBPipeSink.class.getName(), plan.getPipeName()),
-          e);
-      runningPipe = null;
-      throw new PipeException(
-          String.format(
-              "Wrong pipeSink type %s for create pipe %s",
-              runningPipeSink.getType(), runningPipeSink.getName()));
-    } catch (PipeException e) {
-      runningPipe = null;
-      throw e;
+    if (runningPipe.getPipeSink().getType() == PipeSink.PipeSinkType.IoTDB) {
+      try {
+        transportHandler =
+            TransportHandler.getNewTransportHandler(runningPipe, (IoTDBPipeSink) runningPipeSink);
+        sendMsg(RequestType.CREATE);
+      } catch (ClassCastException e) {
+        logger.error(
+            String.format(
+                "Cast Class to %s error when create pipe %s.",
+                IoTDBPipeSink.class.getName(), plan.getPipeName()),
+            e);
+        runningPipe = null;
+        throw new PipeException(
+            String.format(
+                "Wrong pipeSink type %s for create pipe %s",
+                runningPipeSink.getType(), runningPipeSink.getPipeSinkName()));
+      } catch (PipeException e) {
+        runningPipe = null;
+        throw e;
+      }
+    } else { // for external pipe
+      // == start ExternalPipeProcessor for send data to external pip plugin

Review Comment:
   ```suggestion
         // == start ExternalPipeProcessor for send data to external pipe plugin
   ```



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