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 2023/01/12 08:57:56 UTC

[GitHub] [inlong] gosonzhang opened a new pull request, #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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

   
   - Fixes #7226
   


-- 
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] fuweng11 commented on a diff in pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   It is recommended to delete the parameter `inlong_group_id`、`inlong_stream_id` modification directly in the sql statement.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   However, `inlong_group_id` cannot be modified, removing changes to this parameter directly from the sql statement removes unnecessary validation.Or `inlong_group_id` must be not null in request.



-- 
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] fuweng11 commented on a diff in pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   It is recommended to delete the parameter `inlong_group_id`、`inlong_stream_id` modification directly in the sql statement.



-- 
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 #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   Check the request params is necessary, it can throw back to users to know the error detail.



-- 
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] fuweng11 commented on a diff in pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   However, inlong_group_id cannot be modified, removing changes to this parameter directly from the sql statement removes unnecessary validation.Or inlong_group_id must be not null in request.



-- 
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] gosonzhang merged pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


-- 
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] fuweng11 commented on a diff in pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
         if (request == null) {
             throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
         }
-        // check group id
-        if (StringUtils.isBlank(request.getInlongGroupId())) {
-            throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
-        }
-        // check stream id
-        if (StringUtils.isBlank(request.getInlongStreamId())) {
-            throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
-        }
-        // check source type
-        if (StringUtils.isBlank(request.getSourceType())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+        // check record exists
+        StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+                    String.format("not found source record by id=%d", request.getId()));
         }
-        // check source name
-        if (StringUtils.isBlank(request.getSourceName())) {
-            throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+        // check whether modify sourceType
+        if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+            throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+                    "sourceType not allowed modify");
         }
+        // check record version
+        if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+                    String.format("source has already updated with groupId=%s, streamId=%s, name=%s, curVersion=%s",
+                            request.getInlongGroupId(), request.getInlongStreamId(), request.getSourceName(),
+                            request.getVersion()));
+        }
+        // check whether modify groupId
+        if (StringUtils.isNotBlank(request.getInlongGroupId())

Review Comment:
   However, `inlong_group_id` cannot be modified, removing changes to this parameter directly from the sql statement removes unnecessary validation.Or `inlong_group_id` must be not null in request.



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