You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/08/13 15:33:13 UTC

[GitHub] [incubator-seatunnel] ashulin commented on a diff in pull request #2407: [Feature][Connector-V2] Support IoTDB sink

ashulin commented on code in PR #2407:
URL: https://github.com/apache/incubator-seatunnel/pull/2407#discussion_r945160268


##########
seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/sink/IoTDBSink.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.seatunnel.connectors.seatunnel.iotdb.sink;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.sink.SeaTunnelSink;
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.state.IoTDBAggregatedCommitInfo;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.state.IoTDBCommitInfo;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.state.IoTDBSinkState;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+import java.io.IOException;
+
+@AutoService(SeaTunnelSink.class)
+public class IoTDBSink implements SeaTunnelSink<SeaTunnelRow, IoTDBSinkState, IoTDBCommitInfo, IoTDBAggregatedCommitInfo> {

Review Comment:
   ```suggestion
   public class IoTDBSink extend AbstractSimpleSink<SeaTunnelRow, Void> {
   ```
   It's easier to implement,and you can delete actually useless classes;



##########
docs/en/connector-v2/sink/IoTDB.md:
##########
@@ -0,0 +1,111 @@
+# IoTDB
+
+> IoTDB sink connector
+
+## Description
+
+Used to write data to IoTDB. Supports Batch and Streaming mode.
+
+## Options
+
+| name                          | type              | required | default value |
+|-------------------------------|-------------------|----------|---------------|
+| node_urls                     | list              | yes      | -             |
+| username                      | string            | yes      | -             |
+| password                      | string            | yes      | -             |
+| batch_size                    | int               | no       | 1024          |
+| batch_interval_ms             | int               | no       | -             |
+| max_retries                   | int               | no       | -             |
+| retry_backoff_multiplier_ms   | int               | no       | -             |
+| max_retry_backoff_ms          | int               | no       | -             |
+| default_thrift_buffer_size    | int               | no       | -             |
+| max_thrift_frame_size         | int               | no       | -             |
+| zone_id                       | string            | no       | -             |
+| enable_rpc_compression        | boolean           | no       | -             |
+| connection_timeout_in_ms      | int               | no       | -             |
+| timeseries_options            | list              | no       | -             |
+| timeseries_options.path       | string            | no       | -             |
+| timeseries_options.data_type  | string            | no       | -             |
+| common-options                | string            | no       | -             |
+
+### node_urls [list]
+
+`IoTDB` cluster address, the format is `["host:port", ...]`
+
+### username [string]
+
+`IoTDB` user username
+
+### password [string]
+
+`IoTDB` user password
+
+### batch_size [int]
+
+For batch writing, when the number of buffers reaches the number of `batch_size` or the time reaches `batch_interval_ms`, the data will be flushed into the IoTDB
+
+### batch_interval_ms [int]
+
+For batch writing, when the number of buffers reaches the number of `batch_size` or the time reaches `batch_interval_ms`, the data will be flushed into the IoTDB
+
+### max_retries [int]
+
+The number of retries to flush failed
+
+### retry_backoff_multiplier_ms [int]
+
+Using as a multiplier for generating the next delay for backoff
+
+### max_retry_backoff_ms [int]
+
+The amount of time to wait before attempting to retry a request to `IoTDB`
+
+### default_thrift_buffer_size [int]
+
+Thrift init buffer size in `IoTDB` client
+
+### max_thrift_frame_size [int]
+
+Thrift max frame size in `IoTDB` client
+
+### zone_id [string]
+
+java.time.ZoneId in `IoTDB` client
+
+### enable_rpc_compression [boolean]
+
+Enable rpc compression in `IoTDB` client
+
+### connection_timeout_in_ms [int]
+
+The maximum time (in ms) to wait when connect `IoTDB`
+
+### timeseries_options [list]
+
+Timeseries options
+
+### timeseries_options.path [string]
+
+Timeseries path
+
+### timeseries_options.data_type [string]
+
+Timeseries data type
+
+### common options [string]
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Examples
+
+```hocon
+sink {
+  Clickhouse {

Review Comment:
   ```suggestion
     IoTDB {
   ```



##########
seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/sink/IoTDBSinkWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.iotdb.sink;
+
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.config.SinkConfig;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.serialize.DefaultSeaTunnelRowSerializer;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.serialize.IoTDBRecord;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.serialize.SeaTunnelRowSerializer;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.state.IoTDBCommitInfo;
+import org.apache.seatunnel.connectors.seatunnel.iotdb.state.IoTDBSinkState;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.Optional;
+
+@Slf4j
+public class IoTDBSinkWriter implements SinkWriter<SeaTunnelRow, IoTDBCommitInfo, IoTDBSinkState> {

Review Comment:
   ```suggestion
   public class IoTDBSinkWriter extends AbstractSimpleSink<SeaTunnelRow, Void> {
   ```
   Same as above.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org