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/10/26 08:23:16 UTC

[GitHub] [inlong] vernedeng opened a new pull request, #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

vernedeng opened a new pull request, #6294:
URL: https://github.com/apache/inlong/pull/6294

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title Example: [INLONG-XYZ][Component] Title of the pull request
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes #6288 
   
   ### 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
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] 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 follow-up 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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008971806


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/node/AbstractDataNodeOperator.java:
##########
@@ -75,4 +82,14 @@ public void updateOpt(DataNodeRequest request, String operator) {
             throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
         }
     }
+
+    @Override
+    public Map<String, String> parse2SinkParams(DataNodeInfo info) {
+        try {
+            return objectMapper.readValue(info.getExtParams(), HashMap.class);

Review Comment:
   Suggest using `JsonUtils.parseObject`, no need to use try-catch again.



-- 
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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008971806


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/node/AbstractDataNodeOperator.java:
##########
@@ -75,4 +82,14 @@ public void updateOpt(DataNodeRequest request, String operator) {
             throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
         }
     }
+
+    @Override
+    public Map<String, String> parse2SinkParams(DataNodeInfo info) {
+        try {
+            return objectMapper.readValue(info.getExtParams(), HashMap.class);

Review Comment:
   Suggest using `JsonUtils.parseObject`.



-- 
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] [inlong] vernedeng commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig by using MyBatis Cursor

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008997463


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/AbstractSinkOperator.java:
##########
@@ -213,6 +217,23 @@ public void deleteOpt(StreamSinkEntity entity, String operator) {
         sinkFieldMapper.logicDeleteAll(entity.getId());
     }
 
+    @Override
+    public Map<String, String> parse2IdParams(StreamSinkEntity streamSink, List<String> fields) {
+        Map<String, String> param;
+        try {
+            param = objectMapper.readValue(streamSink.getExtParams(), Map.class);
+        } catch (Exception e) {
+            LOGGER.error("cannot parse properties of groupId={}, streamId={}, sinkName={}, the row properties is={}, "
+                            + "exception={}", streamSink.getInlongGroupId(), streamSink.getInlongStreamId(),
+                    streamSink.getSinkName(), streamSink.getExtParams(), e.getMessage());
+            return null;

Review Comment:
   No, the error parsing will produce a **_null_** IdParams, which will be filtered to ensure correct config updating of other groupIds 



-- 
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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008972699


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/AbstractSinkOperator.java:
##########
@@ -213,6 +217,23 @@ public void deleteOpt(StreamSinkEntity entity, String operator) {
         sinkFieldMapper.logicDeleteAll(entity.getId());
     }
 
+    @Override
+    public Map<String, String> parse2IdParams(StreamSinkEntity streamSink, List<String> fields) {
+        Map<String, String> param;
+        try {
+            param = objectMapper.readValue(streamSink.getExtParams(), Map.class);

Review Comment:
   `HashMap.class` may be better.



-- 
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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008973302


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java:
##########
@@ -295,22 +306,19 @@ private void preparePulsar(String pulsarName, boolean isConsumable, String tag)
     }
 
     private void prepareTask(String taskName, String groupId, String clusterName) {
-        StreamSinkEntity entity = new StreamSinkEntity();
-        entity.setInlongGroupId(groupId);
-        entity.setInlongStreamId("1");
-        entity.setSinkType(TEST_SINK_TYPE);
-        entity.setSinkName(taskName);
-        entity.setInlongClusterName(clusterName);
-        entity.setDataNodeName(taskName);
-        entity.setSortTaskName(taskName);
-        entity.setCreator(TEST_CREATOR);
-        Date now = new Date();
-        entity.setCreateTime(now);
-        entity.setModifyTime(now);
-        entity.setIsDeleted(InlongConstants.UN_DELETED);
-        entity.setVersion(InlongConstants.INITIAL_VERSION);
-        entity.setExtParams("{\"delimiter\":\"|\",\"dataType\":\"text\"}");
-        streamSinkEntityMapper.insert(entity);
+        SinkRequest request = new HiveSinkRequest();
+        request.setDataNodeName(taskName);
+        request.setSinkType(SinkType.HIVE);
+        request.setInlongClusterName(clusterName);
+        request.setSinkName(taskName);
+        request.setSortTaskName(taskName);
+        request.setInlongGroupId(groupId);
+        request.setInlongStreamId("1");
+        Map<String, Object> properties = new HashMap<>();
+        properties.put("delimiter", "|");
+        properties.put("dataType", "text");
+        request.setProperties(properties);
+        streamSinkService.save(request, TEST_CREATOR);
     }
 
 }

Review Comment:
   Add one blank line after the end of `}`, thanks.



-- 
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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008973094


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/AbstractSinkOperator.java:
##########
@@ -213,6 +217,23 @@ public void deleteOpt(StreamSinkEntity entity, String operator) {
         sinkFieldMapper.logicDeleteAll(entity.getId());
     }
 
+    @Override
+    public Map<String, String> parse2IdParams(StreamSinkEntity streamSink, List<String> fields) {
+        Map<String, String> param;
+        try {
+            param = objectMapper.readValue(streamSink.getExtParams(), Map.class);
+        } catch (Exception e) {
+            LOGGER.error("cannot parse properties of groupId={}, streamId={}, sinkName={}, the row properties is={}, "
+                            + "exception={}", streamSink.getInlongGroupId(), streamSink.getInlongStreamId(),
+                    streamSink.getSinkName(), streamSink.getExtParams(), e.getMessage());
+            return null;

Review Comment:
   Did it need to return an empty Map?



-- 
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] [inlong] healchow commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008856984


##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamSinkEntityMapper.java:
##########
@@ -117,6 +117,8 @@ List<String> selectExistsStreamId(@Param("groupId") String groupId, @Param("sink
      */
     List<SinkInfo> selectAllConfig(@Param("groupId") String groupId, @Param("idList") List<String> streamIdList);
 
+    List<StreamSinkEntity> selectAllStreamSinks();

Review Comment:
   Suggest using `Cursor` to avoid the OOM.



-- 
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] [inlong] dockerzhang merged pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig by using MyBatis Cursor

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #6294:
URL: https://github.com/apache/inlong/pull/6294


-- 
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] [inlong] vernedeng commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008882309


##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamSinkEntityMapper.java:
##########
@@ -117,6 +117,8 @@ List<String> selectExistsStreamId(@Param("groupId") String groupId, @Param("sink
      */
     List<SinkInfo> selectAllConfig(@Param("groupId") String groupId, @Param("idList") List<String> streamIdList);
 
+    List<StreamSinkEntity> selectAllStreamSinks();

Review Comment:
   fixed, thx



-- 
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] [inlong] vernedeng commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig by using MyBatis Cursor

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008997624


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java:
##########
@@ -295,22 +306,19 @@ private void preparePulsar(String pulsarName, boolean isConsumable, String tag)
     }
 
     private void prepareTask(String taskName, String groupId, String clusterName) {
-        StreamSinkEntity entity = new StreamSinkEntity();
-        entity.setInlongGroupId(groupId);
-        entity.setInlongStreamId("1");
-        entity.setSinkType(TEST_SINK_TYPE);
-        entity.setSinkName(taskName);
-        entity.setInlongClusterName(clusterName);
-        entity.setDataNodeName(taskName);
-        entity.setSortTaskName(taskName);
-        entity.setCreator(TEST_CREATOR);
-        Date now = new Date();
-        entity.setCreateTime(now);
-        entity.setModifyTime(now);
-        entity.setIsDeleted(InlongConstants.UN_DELETED);
-        entity.setVersion(InlongConstants.INITIAL_VERSION);
-        entity.setExtParams("{\"delimiter\":\"|\",\"dataType\":\"text\"}");
-        streamSinkEntityMapper.insert(entity);
+        SinkRequest request = new HiveSinkRequest();
+        request.setDataNodeName(taskName);
+        request.setSinkType(SinkType.HIVE);
+        request.setInlongClusterName(clusterName);
+        request.setSinkName(taskName);
+        request.setSortTaskName(taskName);
+        request.setInlongGroupId(groupId);
+        request.setInlongStreamId("1");
+        Map<String, Object> properties = new HashMap<>();
+        properties.put("delimiter", "|");
+        properties.put("dataType", "text");
+        request.setProperties(properties);
+        streamSinkService.save(request, TEST_CREATOR);
     }
 
 }

Review Comment:
   fixed, thx



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/AbstractSinkOperator.java:
##########
@@ -213,6 +217,23 @@ public void deleteOpt(StreamSinkEntity entity, String operator) {
         sinkFieldMapper.logicDeleteAll(entity.getId());
     }
 
+    @Override
+    public Map<String, String> parse2IdParams(StreamSinkEntity streamSink, List<String> fields) {
+        Map<String, String> param;
+        try {
+            param = objectMapper.readValue(streamSink.getExtParams(), Map.class);

Review Comment:
   fixed, thx



-- 
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] [inlong] vernedeng commented on a diff in pull request #6294: [INLONG-6288][Manager] Refactor getSortClusterConfig by using MyBatis Cursor

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6294:
URL: https://github.com/apache/inlong/pull/6294#discussion_r1008997692


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/node/AbstractDataNodeOperator.java:
##########
@@ -75,4 +82,14 @@ public void updateOpt(DataNodeRequest request, String operator) {
             throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
         }
     }
+
+    @Override
+    public Map<String, String> parse2SinkParams(DataNodeInfo info) {
+        try {
+            return objectMapper.readValue(info.getExtParams(), HashMap.class);

Review Comment:
   fixed, thx



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