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

[GitHub] [rocketmq-connect] sunxiaojian opened a new pull request, #158: [ISSUE #155] Optimize the record converter parser

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

   ## What is the purpose of the change
   
   XXXXX
   
   ## Brief changelog
   
   XX
   
   ## 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: dev-unsubscribe@rocketmq.apache.org

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


[GitHub] [rocketmq-connect] sunxiaojian commented on a diff in pull request #158: [ISSUE #155] Optimize the record converter parser

Posted by GitBox <gi...@apache.org>.
sunxiaojian commented on code in PR #158:
URL: https://github.com/apache/rocketmq-connect/pull/158#discussion_r904703478


##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSinkTask.java:
##########
@@ -583,28 +581,34 @@ private void receiveMessages(List<MessageExt> messages) {
 
     private ConnectRecord convertToSinkDataEntry(MessageExt message) {
         Map<String, String> properties = message.getProperties();
-        Schema schema;
-        Long timestamp;
-        ConnectRecord sinkDataEntry = null;
-        if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
+        ConnectRecord sinkDataEntry;
+        
+        // start convert
+        if (recordConverter instanceof RecordConverter) {

Review Comment:
   > If recordConverter is null,Will it throw a null pointer?
   
   已处理



-- 
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: dev-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 #158: [ISSUE #155] Optimize the record converter parser

Posted by GitBox <gi...@apache.org>.
odbozhou commented on code in PR #158:
URL: https://github.com/apache/rocketmq-connect/pull/158#discussion_r904614982


##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSourceTask.java:
##########
@@ -321,25 +321,27 @@ private void sendRecord() throws InterruptedException, RemotingException, MQClie
                 throw new ConnectException("source connect lack of topic config");
             }
             sourceMessage.setTopic(topic);
-            putExtendMsgProperty(sourceDataEntry, sourceMessage, topic);
-            if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
-                Object payload = sourceDataEntry.getData();
-                if (null != payload) {
-                    final byte[] messageBody = (String.valueOf(payload)).getBytes();
-                    if (messageBody.length > RuntimeConfigDefine.MAX_MESSAGE_SIZE) {
-                        log.error("Send record, message size is greater than {} bytes, sourceDataEntry: {}", RuntimeConfigDefine.MAX_MESSAGE_SIZE, JSON.toJSONString(sourceDataEntry));
-                        continue;
-                    }
-                    sourceMessage.setBody(messageBody);
+            // converter
+            if (recordConverter instanceof RecordConverter) {

Review Comment:
   If recordConverter is null,Will it throw a null pointer?



##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSinkTask.java:
##########
@@ -583,28 +581,34 @@ private void receiveMessages(List<MessageExt> messages) {
 
     private ConnectRecord convertToSinkDataEntry(MessageExt message) {
         Map<String, String> properties = message.getProperties();
-        Schema schema;
-        Long timestamp;
-        ConnectRecord sinkDataEntry = null;
-        if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
+        ConnectRecord sinkDataEntry;
+        
+        // start convert
+        if (recordConverter instanceof RecordConverter) {

Review Comment:
   If recordConverter is null,Will it throw a null pointer?



##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSinkTask.java:
##########
@@ -583,28 +581,34 @@ private void receiveMessages(List<MessageExt> messages) {
 
     private ConnectRecord convertToSinkDataEntry(MessageExt message) {
         Map<String, String> properties = message.getProperties();
-        Schema schema;
-        Long timestamp;
-        ConnectRecord sinkDataEntry = null;
-        if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
+        ConnectRecord sinkDataEntry;
+        
+        // start convert
+        if (recordConverter instanceof RecordConverter) {
+            // timestamp
             String connectTimestamp = properties.get(RuntimeConfigDefine.CONNECT_TIMESTAMP);
-            timestamp = StringUtils.isNotEmpty(connectTimestamp) ? Long.valueOf(connectTimestamp) : null;
-            String connectSchema = properties.get(RuntimeConfigDefine.CONNECT_SCHEMA);
-            schema = StringUtils.isNotEmpty(connectSchema) ? JSON.parseObject(connectSchema, Schema.class) : null;
-            byte[] body = message.getBody();
-            RecordPartition recordPartition = ConnectUtil.convertToRecordPartition(message.getTopic(), message.getBrokerName(), message.getQueueId());
+            Long timestamp = StringUtils.isNotEmpty(connectTimestamp) ? Long.valueOf(connectTimestamp) : null;
 
+            // partition and offset
+            RecordPartition recordPartition = ConnectUtil.convertToRecordPartition(message.getTopic(), message.getBrokerName(), message.getQueueId());
             RecordOffset recordOffset = ConnectUtil.convertToRecordOffset(message.getQueueOffset());
 
-            String bodyStr = new String(body, StandardCharsets.UTF_8);

Review Comment:
   If the converter is null, is it possible to use the previous one as the default processing logic, the default StringConverter?



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

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


[GitHub] [rocketmq-connect] sunxiaojian commented on a diff in pull request #158: [ISSUE #155] Optimize the record converter parser

Posted by GitBox <gi...@apache.org>.
sunxiaojian commented on code in PR #158:
URL: https://github.com/apache/rocketmq-connect/pull/158#discussion_r904703189


##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSinkTask.java:
##########
@@ -583,28 +581,34 @@ private void receiveMessages(List<MessageExt> messages) {
 
     private ConnectRecord convertToSinkDataEntry(MessageExt message) {
         Map<String, String> properties = message.getProperties();
-        Schema schema;
-        Long timestamp;
-        ConnectRecord sinkDataEntry = null;
-        if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
+        ConnectRecord sinkDataEntry;
+        
+        // start convert
+        if (recordConverter instanceof RecordConverter) {
+            // timestamp
             String connectTimestamp = properties.get(RuntimeConfigDefine.CONNECT_TIMESTAMP);
-            timestamp = StringUtils.isNotEmpty(connectTimestamp) ? Long.valueOf(connectTimestamp) : null;
-            String connectSchema = properties.get(RuntimeConfigDefine.CONNECT_SCHEMA);
-            schema = StringUtils.isNotEmpty(connectSchema) ? JSON.parseObject(connectSchema, Schema.class) : null;
-            byte[] body = message.getBody();
-            RecordPartition recordPartition = ConnectUtil.convertToRecordPartition(message.getTopic(), message.getBrokerName(), message.getQueueId());
+            Long timestamp = StringUtils.isNotEmpty(connectTimestamp) ? Long.valueOf(connectTimestamp) : null;
 
+            // partition and offset
+            RecordPartition recordPartition = ConnectUtil.convertToRecordPartition(message.getTopic(), message.getBrokerName(), message.getQueueId());
             RecordOffset recordOffset = ConnectUtil.convertToRecordOffset(message.getQueueOffset());
 
-            String bodyStr = new String(body, StandardCharsets.UTF_8);

Review Comment:
   > If the converter is null, is it possible to use the previous one as the default processing logic, the default StringConverter?
   
   已处理



##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSourceTask.java:
##########
@@ -321,25 +321,27 @@ private void sendRecord() throws InterruptedException, RemotingException, MQClie
                 throw new ConnectException("source connect lack of topic config");
             }
             sourceMessage.setTopic(topic);
-            putExtendMsgProperty(sourceDataEntry, sourceMessage, topic);
-            if (null == recordConverter || recordConverter instanceof RocketMQConverter) {
-                Object payload = sourceDataEntry.getData();
-                if (null != payload) {
-                    final byte[] messageBody = (String.valueOf(payload)).getBytes();
-                    if (messageBody.length > RuntimeConfigDefine.MAX_MESSAGE_SIZE) {
-                        log.error("Send record, message size is greater than {} bytes, sourceDataEntry: {}", RuntimeConfigDefine.MAX_MESSAGE_SIZE, JSON.toJSONString(sourceDataEntry));
-                        continue;
-                    }
-                    sourceMessage.setBody(messageBody);
+            // converter
+            if (recordConverter instanceof RecordConverter) {

Review Comment:
   > If recordConverter is null,Will it throw a null pointer?
   
   已处理



-- 
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: dev-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 #158: [ISSUE #155] Optimize the record converter parser

Posted by GitBox <gi...@apache.org>.
odbozhou commented on code in PR #158:
URL: https://github.com/apache/rocketmq-connect/pull/158#discussion_r903317541


##########
rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/StandaloneConnectStartup.java:
##########
@@ -59,6 +59,7 @@ public class StandaloneConnectStartup {
     public static Properties properties = null;
 
     public static void main(String[] args) {
+        args = new String[]{"-c /Users/sunxiaojian/Desktop/test-config/connect-standalone-copy.conf"};

Review Comment:
   test code?



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

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


[GitHub] [rocketmq-connect] odbozhou merged pull request #158: [ISSUE #155] Optimize the record converter parser

Posted by GitBox <gi...@apache.org>.
odbozhou merged PR #158:
URL: https://github.com/apache/rocketmq-connect/pull/158


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

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