You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/02/02 10:58:23 UTC

[GitHub] [incubator-inlong] luchunliang opened a new pull request #2392: [INLONG-2376] add sdk-common module for supporting new protocol format based on Protobuffer protocol.

luchunliang opened a new pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392


   ### Title Name: [INLONG-2376][Inlong-sdk] add sdk-common module for supporting new protocol format based on Protobuffer protocol.
   
   Fixes #2376 
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve.*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


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

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



[GitHub] [incubator-inlong] codecov-commenter commented on pull request #2392: [INLONG-2376] add sdk-common module for supporting new protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#issuecomment-1030566839


   # [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2392](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (492a170) into [master](https://codecov.io/gh/apache/incubator-inlong/commit/5f10edaa92a83d83f5ea16ef2b7c23a558e6e245?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5f10eda) will **increase** coverage by `0.05%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-inlong/pull/2392/graphs/tree.svg?width=650&height=150&src=pr&token=1EUK92O9K2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #2392      +/-   ##
   ============================================
   + Coverage     12.49%   12.54%   +0.05%     
   - Complexity     1212     1218       +6     
   ============================================
     Files           420      420              
     Lines         36240    36240              
     Branches       5670     5670              
   ============================================
   + Hits           4527     4546      +19     
   + Misses        30914    30886      -28     
   - Partials        799      808       +9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../producer/qltystats/DefaultBrokerRcvQltyStats.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pbmxvbmcvdHViZW1xL2NsaWVudC9wcm9kdWNlci9xbHR5c3RhdHMvRGVmYXVsdEJyb2tlclJjdlFsdHlTdGF0cy5qYXZh) | `45.70% <0.00%> (+0.39%)` | :arrow_up: |
   | [.../tubemq/corebase/policies/FlowCtrlRuleHandler.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybFJ1bGVIYW5kbGVyLmphdmE=) | `34.07% <0.00%> (+1.10%)` | :arrow_up: |
   | [.../inlong/tubemq/corebase/policies/FlowCtrlItem.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybEl0ZW0uamF2YQ==) | `38.88% <0.00%> (+2.22%)` | :arrow_up: |
   | [...ong/tubemq/manager/service/ClusterServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvQ2x1c3RlclNlcnZpY2VJbXBsLmphdmE=) | `52.94% <0.00%> (+2.94%)` | :arrow_up: |
   | [...inlong/tubemq/manager/service/TaskServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvVGFza1NlcnZpY2VJbXBsLmphdmE=) | `8.53% <0.00%> (+4.87%)` | :arrow_up: |
   | [...nlong/tubemq/corebase/policies/FlowCtrlResult.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybFJlc3VsdC5qYXZh) | `60.00% <0.00%> (+60.00%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [67b5039...492a170](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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

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



[GitHub] [incubator-inlong] codecov-commenter edited a comment on pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#issuecomment-1030566839


   # [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2392](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ea2089e) into [master](https://codecov.io/gh/apache/incubator-inlong/commit/5f10edaa92a83d83f5ea16ef2b7c23a558e6e245?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5f10eda) will **increase** coverage by `0.04%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-inlong/pull/2392/graphs/tree.svg?width=650&height=150&src=pr&token=1EUK92O9K2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #2392      +/-   ##
   ============================================
   + Coverage     12.49%   12.53%   +0.04%     
   - Complexity     1212     1218       +6     
   ============================================
     Files           420      420              
     Lines         36240    36255      +15     
     Branches       5670     5674       +4     
   ============================================
   + Hits           4527     4545      +18     
   + Misses        30914    30901      -13     
   - Partials        799      809      +10     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../client/producer/qltystats/BrokerStatsItemSet.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pbmxvbmcvdHViZW1xL2NsaWVudC9wcm9kdWNlci9xbHR5c3RhdHMvQnJva2VyU3RhdHNJdGVtU2V0LmphdmE=) | `67.44% <0.00%> (-4.66%)` | :arrow_down: |
   | [...inlong/tubemq/manager/controller/TubeMQResult.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL2NvbnRyb2xsZXIvVHViZU1RUmVzdWx0LmphdmE=) | `60.00% <0.00%> (-3.16%)` | :arrow_down: |
   | [.../producer/qltystats/DefaultBrokerRcvQltyStats.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pbmxvbmcvdHViZW1xL2NsaWVudC9wcm9kdWNlci9xbHR5c3RhdHMvRGVmYXVsdEJyb2tlclJjdlFsdHlTdGF0cy5qYXZh) | `44.14% <0.00%> (-1.18%)` | :arrow_down: |
   | [...long/tubemq/manager/service/MasterServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvTWFzdGVyU2VydmljZUltcGwuamF2YQ==) | `5.79% <0.00%> (-0.87%)` | :arrow_down: |
   | [...ager/controller/cluster/request/AddClusterReq.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL2NvbnRyb2xsZXIvY2x1c3Rlci9yZXF1ZXN0L0FkZENsdXN0ZXJSZXEuamF2YQ==) | `75.00% <0.00%> (ø)` | |
   | [.../tubemq/corebase/policies/FlowCtrlRuleHandler.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybFJ1bGVIYW5kbGVyLmphdmE=) | `34.07% <0.00%> (+1.10%)` | :arrow_up: |
   | [.../inlong/tubemq/corebase/policies/FlowCtrlItem.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9jb3JlYmFzZS9wb2xpY2llcy9GbG93Q3RybEl0ZW0uamF2YQ==) | `38.88% <0.00%> (+2.22%)` | :arrow_up: |
   | [...inlong/tubemq/manager/service/TaskServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvVGFza1NlcnZpY2VJbXBsLmphdmE=) | `8.53% <0.00%> (+4.87%)` | :arrow_up: |
   | [.../manager/controller/cluster/ClusterController.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL2NvbnRyb2xsZXIvY2x1c3Rlci9DbHVzdGVyQ29udHJvbGxlci5qYXZh) | `26.08% <0.00%> (+5.15%)` | :arrow_up: |
   | [...ong/tubemq/manager/service/ClusterServiceImpl.java](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtbWFuYWdlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW5sb25nL3R1YmVtcS9tYW5hZ2VyL3NlcnZpY2UvQ2x1c3RlclNlcnZpY2VJbXBsLmphdmE=) | `55.55% <0.00%> (+5.55%)` | :arrow_up: |
   | ... and [1 more](https://codecov.io/gh/apache/incubator-inlong/pull/2392/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [67b5039...ea2089e](https://codecov.io/gh/apache/incubator-inlong/pull/2392?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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

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



[GitHub] [incubator-inlong] wardlican commented on a change in pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
wardlican commented on a change in pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#discussion_r803251327



##########
File path: inlong-sdk/sdk-common/src/main/java/org/apache/inlong/sdk/commons/protocol/EventUtils.java
##########
@@ -0,0 +1,215 @@
+/**
+ * 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.inlong.sdk.commons.protocol;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.INLONG_COMPRESSED_TYPE;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MapFieldEntry;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObj;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObjs;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePack;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePackHeader;
+import org.apache.inlong.sdk.commons.utils.GzipUtils;
+import org.xerial.snappy.Snappy;
+
+import com.google.protobuf.ByteString;
+
+/**
+ * EventUtils
+ */
+public class EventUtils {
+
+    /**
+     * encode
+     * 
+     * @param  inlongGroupId
+     * @param  inlongStreamId
+     * @param  compressedType
+     * @param  events
+     * @return                MessagePack
+     * @throws IOException
+     */
+    public static MessagePack encodeSdkEvents(String inlongGroupId, String inlongStreamId,
+            INLONG_COMPRESSED_TYPE compressedType, List<SdkEvent> events) throws IOException {
+        // MessageObjs
+        MessageObjs.Builder objsBuilder = MessageObjs.newBuilder();
+        for (SdkEvent event : events) {
+            MessageObj.Builder objBuilder = MessageObj.newBuilder();
+            objBuilder.setMsgTime(event.getMsgTime());
+            objBuilder.setSourceIp(event.getSourceIp());
+            objBuilder.setBody(ByteString.copyFrom(event.getBody()));
+            objsBuilder.addMsgs(objBuilder.build());
+        }
+        MessageObjs objs = objsBuilder.build();
+        byte[] srcBytes = objs.toByteArray();
+        byte[] compressedBytes = null;
+        switch (compressedType) {
+            case INLONG_SNAPPY :
+                compressedBytes = Snappy.compress(srcBytes);
+                break;
+            case INLONG_GZ :
+                compressedBytes = GzipUtils.compress(srcBytes);
+                break;
+            case INLONG_NO_COMPRESS :
+            default :
+                compressedBytes = srcBytes;
+                break;
+        }
+        // MessagePack
+        MessagePack.Builder packBuilder = MessagePack.newBuilder();
+        packBuilder.setCompressBytes(ByteString.copyFrom(compressedBytes));
+        // MessagePackHeader
+        MessagePackHeader.Builder headerBuilder = MessagePackHeader.newBuilder();
+        // string inlongGroupId = 1; //inlongGroupId
+        headerBuilder.setInlongGroupId(inlongGroupId);
+        // string inlongStreamId = 2; //inlongStreamId
+        headerBuilder.setInlongStreamId(inlongStreamId);
+        // int64 packTime = 3; //pack time, milliseconds
+        headerBuilder.setPackTime(System.currentTimeMillis());
+        // int32 msgCount = 4; //message count
+        headerBuilder.setMsgCount(events.size());
+        // int32 srcLength = 5; //total length of raw messages body
+        headerBuilder.setSrcLength(srcBytes.length);
+        // int32 compressLen = 6; //compress length of messages
+        headerBuilder.setCompressLen(compressedBytes.length);
+        // INLONG_COMPRESSED_TYPE compressType = 7; //compress type
+        headerBuilder.setCompressType(compressedType);
+        // map<string, string> params = 8; //additional parameters
+        packBuilder.setHeader(headerBuilder.build());
+        return packBuilder.build();
+    }
+
+    /**
+     * decodeSdkPack
+     * 
+     * @param  packBytes
+     * @param  offset
+     * @param  length
+     * @return             List,ProxyEvent

Review comment:
       ditto




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

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



[GitHub] [incubator-inlong] dockerzhang merged pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392


   


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

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#discussion_r803256194



##########
File path: inlong-sdk/sdk-common/src/main/java/org/apache/inlong/sdk/commons/protocol/EventUtils.java
##########
@@ -0,0 +1,215 @@
+/**
+ * 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.inlong.sdk.commons.protocol;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.INLONG_COMPRESSED_TYPE;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MapFieldEntry;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObj;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObjs;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePack;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePackHeader;
+import org.apache.inlong.sdk.commons.utils.GzipUtils;
+import org.xerial.snappy.Snappy;
+
+import com.google.protobuf.ByteString;
+
+/**
+ * EventUtils
+ */
+public class EventUtils {
+
+    /**
+     * encode
+     * 
+     * @param  inlongGroupId
+     * @param  inlongStreamId
+     * @param  compressedType
+     * @param  events
+     * @return                MessagePack

Review comment:
       fixed

##########
File path: inlong-sdk/sdk-common/src/main/java/org/apache/inlong/sdk/commons/protocol/EventUtils.java
##########
@@ -0,0 +1,215 @@
+/**
+ * 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.inlong.sdk.commons.protocol;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.INLONG_COMPRESSED_TYPE;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MapFieldEntry;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObj;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObjs;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePack;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePackHeader;
+import org.apache.inlong.sdk.commons.utils.GzipUtils;
+import org.xerial.snappy.Snappy;
+
+import com.google.protobuf.ByteString;
+
+/**
+ * EventUtils
+ */
+public class EventUtils {
+
+    /**
+     * encode
+     * 
+     * @param  inlongGroupId
+     * @param  inlongStreamId
+     * @param  compressedType
+     * @param  events
+     * @return                MessagePack
+     * @throws IOException
+     */
+    public static MessagePack encodeSdkEvents(String inlongGroupId, String inlongStreamId,
+            INLONG_COMPRESSED_TYPE compressedType, List<SdkEvent> events) throws IOException {
+        // MessageObjs
+        MessageObjs.Builder objsBuilder = MessageObjs.newBuilder();
+        for (SdkEvent event : events) {
+            MessageObj.Builder objBuilder = MessageObj.newBuilder();
+            objBuilder.setMsgTime(event.getMsgTime());
+            objBuilder.setSourceIp(event.getSourceIp());
+            objBuilder.setBody(ByteString.copyFrom(event.getBody()));
+            objsBuilder.addMsgs(objBuilder.build());
+        }
+        MessageObjs objs = objsBuilder.build();
+        byte[] srcBytes = objs.toByteArray();
+        byte[] compressedBytes = null;
+        switch (compressedType) {
+            case INLONG_SNAPPY :
+                compressedBytes = Snappy.compress(srcBytes);
+                break;
+            case INLONG_GZ :
+                compressedBytes = GzipUtils.compress(srcBytes);
+                break;
+            case INLONG_NO_COMPRESS :
+            default :
+                compressedBytes = srcBytes;
+                break;
+        }
+        // MessagePack
+        MessagePack.Builder packBuilder = MessagePack.newBuilder();
+        packBuilder.setCompressBytes(ByteString.copyFrom(compressedBytes));
+        // MessagePackHeader
+        MessagePackHeader.Builder headerBuilder = MessagePackHeader.newBuilder();
+        // string inlongGroupId = 1; //inlongGroupId
+        headerBuilder.setInlongGroupId(inlongGroupId);
+        // string inlongStreamId = 2; //inlongStreamId
+        headerBuilder.setInlongStreamId(inlongStreamId);
+        // int64 packTime = 3; //pack time, milliseconds
+        headerBuilder.setPackTime(System.currentTimeMillis());
+        // int32 msgCount = 4; //message count
+        headerBuilder.setMsgCount(events.size());
+        // int32 srcLength = 5; //total length of raw messages body
+        headerBuilder.setSrcLength(srcBytes.length);
+        // int32 compressLen = 6; //compress length of messages
+        headerBuilder.setCompressLen(compressedBytes.length);
+        // INLONG_COMPRESSED_TYPE compressType = 7; //compress type
+        headerBuilder.setCompressType(compressedType);
+        // map<string, string> params = 8; //additional parameters
+        packBuilder.setHeader(headerBuilder.build());
+        return packBuilder.build();
+    }
+
+    /**
+     * decodeSdkPack
+     * 
+     * @param  packBytes
+     * @param  offset
+     * @param  length
+     * @return             List,ProxyEvent

Review comment:
       fixed




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

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



[GitHub] [incubator-inlong] imvan removed a comment on pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
imvan removed a comment on pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#issuecomment-1034433421


   lgtm


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

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



[GitHub] [incubator-inlong] imvan commented on pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
imvan commented on pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#issuecomment-1034433421


   lgtm


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

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



[GitHub] [incubator-inlong] imvan commented on a change in pull request #2392: [INLONG-2376] add sdk-common module for supporting PB compression protocol format based on Protobuffer protocol.

Posted by GitBox <gi...@apache.org>.
imvan commented on a change in pull request #2392:
URL: https://github.com/apache/incubator-inlong/pull/2392#discussion_r803250812



##########
File path: inlong-sdk/sdk-common/src/main/java/org/apache/inlong/sdk/commons/protocol/EventUtils.java
##########
@@ -0,0 +1,215 @@
+/**
+ * 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.inlong.sdk.commons.protocol;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.INLONG_COMPRESSED_TYPE;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MapFieldEntry;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObj;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessageObjs;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePack;
+import org.apache.inlong.sdk.commons.protocol.ProxySdk.MessagePackHeader;
+import org.apache.inlong.sdk.commons.utils.GzipUtils;
+import org.xerial.snappy.Snappy;
+
+import com.google.protobuf.ByteString;
+
+/**
+ * EventUtils
+ */
+public class EventUtils {
+
+    /**
+     * encode
+     * 
+     * @param  inlongGroupId
+     * @param  inlongStreamId
+     * @param  compressedType
+     * @param  events
+     * @return                MessagePack

Review comment:
       too much space




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

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