You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/16 10:11:41 UTC

[GitHub] [rocketmq-connect] Oliverwqcwrw opened a new pull request, #398: [ISSUE #392] Add iotdb source connector

Oliverwqcwrw opened a new pull request, #398:
URL: https://github.com/apache/rocketmq-connect/pull/398

   ## What is the purpose of the change
   
   Close #392 
   
   ## Brief changelog
   
   Add iotdb source connector
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq-connect/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] odbozhou commented on a diff in pull request #398: [ISSUE #392] Add iotdb source connector

Posted by "odbozhou (via GitHub)" <gi...@apache.org>.
odbozhou commented on code in PR #398:
URL: https://github.com/apache/rocketmq-connect/pull/398#discussion_r1094401658


##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/exception/IotdbRuntimeException.java:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.rocketmq.connect.iotdb.exception;
+
+public class IotdbRuntimeException extends RuntimeException {

Review Comment:
   Inheriting ConnectException may be a better choice



##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/replicator/source/IotdbQuery.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.rocketmq.connect.iotdb.replicator.source;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.data.RecordOffset;
+import java.util.List;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.SessionDataSet;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbQuery {
+
+    private static final Logger log = LoggerFactory.getLogger(IotdbQuery.class);
+
+    private IotdbReplicator replicator;
+
+    private IotdbConfig config;
+
+    private Session session;
+
+    public IotdbQuery(IotdbReplicator replicator) {
+        this.replicator = replicator;
+        this.config = replicator.getConfig();
+        session =
+            new Session.Builder()
+                .host(config.getIotdbHost())
+                .port(config.getIotdbPort())
+                .build();
+        try {
+            session.open();
+        } catch (IoTDBConnectionException e) {
+            log.error("iotdb session open failed", e);
+        }
+
+    }
+
+    public void start(RecordOffset recordOffset, KeyValue keyValue) {
+
+
+        String path = null;
+        try {
+            path = keyValue.getString(IotdbConstant.IOTDB_PATH);
+            if (path == null || path.trim().equals("")) {
+                log.warn("the path is empty,please check config");
+                return;
+            }
+            long time = 0;
+            if (recordOffset != null && recordOffset.getOffset() != null && recordOffset.getOffset().size() > 0) {
+                final Long offsetValue = (Long) recordOffset.getOffset().get(keyValue.getString(IotdbConstant.IOTDB_PARTITION) + path);
+                time = offsetValue;
+            }
+            int limit = 500;
+            long offset = 1;
+            String sql = "select * from " + path + " where time > " + time + " limit " + limit + " offset " + offset;

Review Comment:
   If you just use timestamps, is it impossible to guarantee the uniqueness of the data? It is possible that some data have exactly the same time



##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/replicator/source/IotdbQuery.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.rocketmq.connect.iotdb.replicator.source;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.data.RecordOffset;
+import java.util.List;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.SessionDataSet;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbQuery {
+
+    private static final Logger log = LoggerFactory.getLogger(IotdbQuery.class);
+
+    private IotdbReplicator replicator;
+
+    private IotdbConfig config;
+
+    private Session session;
+
+    public IotdbQuery(IotdbReplicator replicator) {
+        this.replicator = replicator;
+        this.config = replicator.getConfig();
+        session =

Review Comment:
   Is it more appropriate to open the session in start ?



##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/connector/IotdbSourceConnector.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.rocketmq.connect.iotdb.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.Task;
+import io.openmessaging.connector.api.component.task.source.SourceConnector;
+import io.openmessaging.internal.DefaultKeyValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.apache.rocketmq.connect.iotdb.exception.IotdbRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbSourceConnector extends SourceConnector {
+
+    private Logger logger = LoggerFactory.getLogger(IotdbSourceConnector.class);
+
+    private KeyValue keyValue;
+
+    private IotdbConfig config;
+
+    @Override
+    public List<KeyValue> taskConfigs(int maxTasks) {

Review Comment:
   maxTasks does not take effect



-- 
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@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] Oliverwqcwrw merged pull request #398: [ISSUE #392] Add iotdb source connector

Posted by "Oliverwqcwrw (via GitHub)" <gi...@apache.org>.
Oliverwqcwrw merged PR #398:
URL: https://github.com/apache/rocketmq-connect/pull/398


-- 
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@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #398: [ISSUE #392] Add iotdb source connector

Posted by "Oliverwqcwrw (via GitHub)" <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #398:
URL: https://github.com/apache/rocketmq-connect/pull/398#discussion_r1095250372


##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/replicator/source/IotdbQuery.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.rocketmq.connect.iotdb.replicator.source;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.data.RecordOffset;
+import java.util.List;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.SessionDataSet;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbQuery {
+
+    private static final Logger log = LoggerFactory.getLogger(IotdbQuery.class);
+
+    private IotdbReplicator replicator;
+
+    private IotdbConfig config;
+
+    private Session session;
+
+    public IotdbQuery(IotdbReplicator replicator) {
+        this.replicator = replicator;
+        this.config = replicator.getConfig();
+        session =
+            new Session.Builder()
+                .host(config.getIotdbHost())
+                .port(config.getIotdbPort())
+                .build();
+        try {
+            session.open();
+        } catch (IoTDBConnectionException e) {
+            log.error("iotdb session open failed", e);
+        }
+
+    }
+
+    public void start(RecordOffset recordOffset, KeyValue keyValue) {
+
+
+        String path = null;
+        try {
+            path = keyValue.getString(IotdbConstant.IOTDB_PATH);
+            if (path == null || path.trim().equals("")) {
+                log.warn("the path is empty,please check config");
+                return;
+            }
+            long time = 0;
+            if (recordOffset != null && recordOffset.getOffset() != null && recordOffset.getOffset().size() > 0) {
+                final Long offsetValue = (Long) recordOffset.getOffset().get(keyValue.getString(IotdbConstant.IOTDB_PARTITION) + path);
+                time = offsetValue;
+            }
+            int limit = 500;
+            long offset = 1;
+            String sql = "select * from " + path + " where time > " + time + " limit " + limit + " offset " + offset;

Review Comment:
   In my opinion, data reporting in the Internet of Things scenario pays more attention to the data at a certain point in time and the trend change of the data over time. The uniqueness of the data mainly refers to the data at a certain point in time, such as the temperature of the computer reported per second. Even if the data is repeatedly reported, the change trend of the data will not be affected, so the data at all points in time is mainly pulled
   
   Please let me know if i am missing something



-- 
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@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #398: [ISSUE #392] Add iotdb source connector

Posted by "Oliverwqcwrw (via GitHub)" <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #398:
URL: https://github.com/apache/rocketmq-connect/pull/398#discussion_r1095248334


##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/connector/IotdbSourceConnector.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.rocketmq.connect.iotdb.connector;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.component.task.Task;
+import io.openmessaging.connector.api.component.task.source.SourceConnector;
+import io.openmessaging.internal.DefaultKeyValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.apache.rocketmq.connect.iotdb.exception.IotdbRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbSourceConnector extends SourceConnector {
+
+    private Logger logger = LoggerFactory.getLogger(IotdbSourceConnector.class);
+
+    private KeyValue keyValue;
+
+    private IotdbConfig config;
+
+    @Override
+    public List<KeyValue> taskConfigs(int maxTasks) {

Review Comment:
   done



##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/exception/IotdbRuntimeException.java:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.rocketmq.connect.iotdb.exception;
+
+public class IotdbRuntimeException extends RuntimeException {

Review Comment:
   done



-- 
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@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #398: [ISSUE #392] Add iotdb source connector

Posted by "Oliverwqcwrw (via GitHub)" <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #398:
URL: https://github.com/apache/rocketmq-connect/pull/398#discussion_r1095248459


##########
connectors/rocketmq-connect-iotdb/src/main/java/org/apache/rocketmq/connect/iotdb/replicator/source/IotdbQuery.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.rocketmq.connect.iotdb.replicator.source;
+
+import io.openmessaging.KeyValue;
+import io.openmessaging.connector.api.data.RecordOffset;
+import java.util.List;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.SessionDataSet;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConfig;
+import org.apache.rocketmq.connect.iotdb.config.IotdbConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IotdbQuery {
+
+    private static final Logger log = LoggerFactory.getLogger(IotdbQuery.class);
+
+    private IotdbReplicator replicator;
+
+    private IotdbConfig config;
+
+    private Session session;
+
+    public IotdbQuery(IotdbReplicator replicator) {
+        this.replicator = replicator;
+        this.config = replicator.getConfig();
+        session =

Review Comment:
   done



-- 
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@rocketmq.apache.org

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