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/06/18 11:59:43 UTC

[GitHub] [incubator-inlong] gong commented on a diff in pull request #4694: [INLONG-4632][Manager] Abstract operations on sink configuration to reduce repetitive code

gong commented on code in PR #4694:
URL: https://github.com/apache/incubator-inlong/pull/4694#discussion_r900853930


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/ck/ClickHouseSinkOperation.java:
##########
@@ -179,60 +104,26 @@ public PageInfo<? extends SinkListResponse> getPageInfo(Page<StreamSinkEntity> e
     }
 
     @Override
-    public void updateOpt(SinkRequest request, String operator) {
-        String sinkType = request.getSinkType();
-        Preconditions.checkTrue(SinkType.SINK_CLICKHOUSE.equals(sinkType),
-                String.format(ErrorCodeEnum.SINK_TYPE_NOT_SAME.getMessage(), SinkType.SINK_CLICKHOUSE, sinkType));
-
-        StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(request.getId());
-        Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
+    protected void setTargetEntity(SinkRequest request, StreamSinkEntity targetEntity) {
+        Preconditions.checkTrue(this.getSinkType().equals(request.getSinkType()),
+                ErrorCodeEnum.SINK_TYPE_NOT_SUPPORT.getMessage() + ": " + getSinkType());
         ClickHouseSinkRequest sinkRequest = (ClickHouseSinkRequest) request;
-        CommonBeanUtils.copyProperties(sinkRequest, entity, true);
         try {
             ClickHouseSinkDTO dto = ClickHouseSinkDTO.getFromRequest(sinkRequest);
-            entity.setExtParams(objectMapper.writeValueAsString(dto));
+            targetEntity.setExtParams(objectMapper.writeValueAsString(dto));
         } catch (Exception e) {
-            throw new BusinessException(ErrorCodeEnum.SINK_INFO_INCORRECT.getMessage());
+            throw new BusinessException(ErrorCodeEnum.SINK_SAVE_FAILED.getMessage());

Review Comment:
   I suggest print full exception stack in here and other like here. Because it is convenient to analyse problem when throw exception.



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