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/13 02:16:25 UTC

[GitHub] [inlong] fuweng11 commented on a diff in pull request #7227: [INLONG-7226][Manager] Optimize OpenStreamSourceController implementation

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