fuweng11 commented on code in PR #8892:
URL: https://github.com/apache/inlong/pull/8892#discussion_r1326690956


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/node/cls/TencentClsDataNodeDTO.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.manager.pojo.node.cls;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Tencent cloud log service data node info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Tencent cloud log service data node info")
+public class TencentClsDataNodeDTO {
+
+    /**
+     *Tencent cloud log service master account
+     */
+    private String mainAccountID;
+
+    /**
+     *Tencent cloud log service subAccount
+     */
+    private String subAccountID;

Review Comment:
   subAccountId



##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/node/cls/TencentClsDataNodeDTO.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.manager.pojo.node.cls;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Tencent cloud log service data node info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Tencent cloud log service data node info")
+public class TencentClsDataNodeDTO {
+
+    /**
+     *Tencent cloud log service master account
+     */
+    private String mainAccountID;

Review Comment:
   mainAccountId



##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/node/cls/TencentClsDataNodeInfo.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.manager.pojo.node.cls;
+
+import org.apache.inlong.manager.common.consts.DataNodeType;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonTypeDefine;
+import org.apache.inlong.manager.pojo.node.DataNodeInfo;
+import org.apache.inlong.manager.pojo.node.DataNodeRequest;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+/**
+ * Tencent cloud log service data node info
+ */
+@Data
+@SuperBuilder
+@AllArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeDefine(value = DataNodeType.ELASTICSEARCH)
+@ApiModel("Tencent cloud log service data node info")
+public class TencentClsDataNodeInfo extends DataNodeInfo {
+
+    /**
+     *Tencent cloud log service master account
+     */
+    private String mainAccountID;

Review Comment:
   Ditto.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/cls/TencentClsResourceOperator.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.manager.service.resource.sink.cls;
+
+import org.apache.inlong.manager.common.consts.DataNodeType;
+import org.apache.inlong.manager.common.consts.InlongConstants;
+import org.apache.inlong.manager.common.consts.SinkType;
+import org.apache.inlong.manager.common.enums.SinkStatus;
+import org.apache.inlong.manager.common.exceptions.WorkflowException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.apache.inlong.manager.dao.entity.DataNodeEntity;
+import org.apache.inlong.manager.dao.entity.StreamSinkEntity;
+import org.apache.inlong.manager.dao.mapper.DataNodeEntityMapper;
+import org.apache.inlong.manager.dao.mapper.StreamSinkEntityMapper;
+import org.apache.inlong.manager.pojo.node.cls.TencentClsDataNodeDTO;
+import org.apache.inlong.manager.pojo.sink.SinkInfo;
+import org.apache.inlong.manager.pojo.sink.cls.TencentClsSinkDTO;
+import org.apache.inlong.manager.service.resource.sink.SinkResourceOperator;
+import org.apache.inlong.manager.service.sink.StreamSinkService;
+
+import com.tencentcloudapi.cls.v20201016.ClsClient;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicRequest;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicResponse;
+import com.tencentcloudapi.cls.v20201016.models.Tag;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TencentClsResourceOperator implements SinkResourceOperator {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(TencentClsResourceOperator.class);
+
+    @Autowired
+    private DataNodeEntityMapper dataNodeEntityMapper;
+    @Autowired
+    private StreamSinkService sinkService;
+    @Autowired
+    private StreamSinkEntityMapper streamSinkEntityMapper;
+
+    @Override
+    public Boolean accept(String sinkType) {
+        return SinkType.CLS.equals(sinkType);
+    }
+
+    @Override
+    public void createSinkResource(SinkInfo sinkInfo) {
+        LOG.info("begin to create sink resources sinkId={}", sinkInfo.getId());
+        if 
(SinkStatus.CONFIG_SUCCESSFUL.getCode().equals(sinkInfo.getStatus())) {
+            LOG.warn("sink resource [" + sinkInfo.getId() + "] already 
success, skip to create");
+            return;
+        } else if 
(InlongConstants.DISABLE_CREATE_RESOURCE.equals(sinkInfo.getEnableCreateResource()))
 {
+            LOG.warn("create resource was disabled, skip to create for [" + 
sinkInfo.getId() + "]");
+            return;
+        }
+        this.createTopicID(sinkInfo);
+    }
+
+    private void createTopicID(SinkInfo sinkInfo) {
+        TencentClsDataNodeDTO tencentClsDataNode = 
getTencentClsDataNode(sinkInfo);
+        TencentClsSinkDTO tencentClsSinkDTO = 
JsonUtils.parseObject(sinkInfo.getExtParams(), TencentClsSinkDTO.class);
+        try {
+            Credential cred = new 
Credential(tencentClsDataNode.getManageSecretId(),
+                    tencentClsDataNode.getManageSecretId());
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint(tencentClsDataNode.getEndpoint());
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            ClsClient client = new ClsClient(cred, 
tencentClsDataNode.getRegion(), clientProfile);
+            CreateTopicRequest req = new CreateTopicRequest();
+            String[] allTags = tencentClsSinkDTO.getTag().split("\\|");
+            Tag[] tags = convertTags(allTags);
+            req.setTags(tags);
+            req.setLogsetId(tencentClsDataNode.getLogSetID());
+            req.setTopicName(tencentClsSinkDTO.getTopicName());
+            CreateTopicResponse resp = client.CreateTopic(req);
+            LOG.info("create cls topic {} success ,topicId {}", 
tencentClsSinkDTO.getTopicName(), resp.getTopicId());
+            tencentClsSinkDTO.setTopicID(resp.getTopicId());
+            sinkInfo.setExtParams(JsonUtils.toJsonString(tencentClsSinkDTO));
+            StreamSinkEntity streamSinkEntity = new StreamSinkEntity();
+            CommonBeanUtils.copyProperties(sinkInfo, streamSinkEntity, true);
+            streamSinkEntityMapper.updateByIdSelective(streamSinkEntity);
+            String info = "success to create cls resource";
+            sinkService.updateStatus(sinkInfo.getId(), 
SinkStatus.CONFIG_SUCCESSFUL.getCode(), info);
+            LOG.info("update cls sink info status {} success ,topicId {}", 
tencentClsSinkDTO.getTopicName(),
+                    streamSinkEntity.getExtParams());
+        } catch (TencentCloudSDKException e) {
+            String errMsg = "Create cls topic  failed: " + e.getMessage();
+            LOG.error(errMsg, e);
+            sinkService.updateStatus(sinkInfo.getId(), 
SinkStatus.CONFIG_FAILED.getCode(), errMsg);
+            throw new WorkflowException(errMsg);
+        }
+    }
+
+    private Tag[] convertTags(String[] allTags) {
+        Tag[] tags = new Tag[allTags.length];
+        for (int i = 0; i < allTags.length; i++) {
+            String tag = allTags[i];
+            String[] keyAndValueOfTag = tag.split(":");

Review Comment:
   Please use `InlongConstants.COLON`



##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/node/cls/TencentClsDataNodeDTO.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.manager.pojo.node.cls;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Tencent cloud log service data node info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Tencent cloud log service data node info")
+public class TencentClsDataNodeDTO {
+
+    /**
+     *Tencent cloud log service master account
+     */
+    private String mainAccountID;
+
+    /**
+     *Tencent cloud log service subAccount
+     */
+    private String subAccountID;
+
+    /**
+     * Tencent cloud log service send api secretKey
+     */
+    private String sendSecretKey;
+
+    /**
+     * Tencent cloud log service send api secretId
+     */
+    private String sendSecretId;
+
+    /**
+     * Tencent cloud log service manage api secretKey
+     */
+    private String manageSecretKey;
+
+    /**
+     * Tencent cloud log service manage api secretId
+     */
+    private String manageSecretId;
+
+    /**
+     * Tencent cloud log service endpoint
+     */
+    private String endpoint;
+
+    /**
+     * Tencent cloud log service region
+     */
+    private String region;
+
+    /**
+     * Tencent cloud log service  set id
+     */
+    private String logSetID;

Review Comment:
    logSetId



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/cls/TencentClsResourceOperator.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.manager.service.resource.sink.cls;
+
+import org.apache.inlong.manager.common.consts.DataNodeType;
+import org.apache.inlong.manager.common.consts.InlongConstants;
+import org.apache.inlong.manager.common.consts.SinkType;
+import org.apache.inlong.manager.common.enums.SinkStatus;
+import org.apache.inlong.manager.common.exceptions.WorkflowException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.apache.inlong.manager.dao.entity.DataNodeEntity;
+import org.apache.inlong.manager.dao.entity.StreamSinkEntity;
+import org.apache.inlong.manager.dao.mapper.DataNodeEntityMapper;
+import org.apache.inlong.manager.dao.mapper.StreamSinkEntityMapper;
+import org.apache.inlong.manager.pojo.node.cls.TencentClsDataNodeDTO;
+import org.apache.inlong.manager.pojo.sink.SinkInfo;
+import org.apache.inlong.manager.pojo.sink.cls.TencentClsSinkDTO;
+import org.apache.inlong.manager.service.resource.sink.SinkResourceOperator;
+import org.apache.inlong.manager.service.sink.StreamSinkService;
+
+import com.tencentcloudapi.cls.v20201016.ClsClient;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicRequest;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicResponse;
+import com.tencentcloudapi.cls.v20201016.models.Tag;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TencentClsResourceOperator implements SinkResourceOperator {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(TencentClsResourceOperator.class);
+
+    @Autowired
+    private DataNodeEntityMapper dataNodeEntityMapper;
+    @Autowired
+    private StreamSinkService sinkService;
+    @Autowired
+    private StreamSinkEntityMapper streamSinkEntityMapper;
+
+    @Override
+    public Boolean accept(String sinkType) {
+        return SinkType.CLS.equals(sinkType);
+    }
+
+    @Override
+    public void createSinkResource(SinkInfo sinkInfo) {
+        LOG.info("begin to create sink resources sinkId={}", sinkInfo.getId());
+        if 
(SinkStatus.CONFIG_SUCCESSFUL.getCode().equals(sinkInfo.getStatus())) {
+            LOG.warn("sink resource [" + sinkInfo.getId() + "] already 
success, skip to create");
+            return;
+        } else if 
(InlongConstants.DISABLE_CREATE_RESOURCE.equals(sinkInfo.getEnableCreateResource()))
 {
+            LOG.warn("create resource was disabled, skip to create for [" + 
sinkInfo.getId() + "]");
+            return;
+        }
+        this.createTopicID(sinkInfo);
+    }
+
+    private void createTopicID(SinkInfo sinkInfo) {
+        TencentClsDataNodeDTO tencentClsDataNode = 
getTencentClsDataNode(sinkInfo);
+        TencentClsSinkDTO tencentClsSinkDTO = 
JsonUtils.parseObject(sinkInfo.getExtParams(), TencentClsSinkDTO.class);
+        try {
+            Credential cred = new 
Credential(tencentClsDataNode.getManageSecretId(),
+                    tencentClsDataNode.getManageSecretId());
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint(tencentClsDataNode.getEndpoint());
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            ClsClient client = new ClsClient(cred, 
tencentClsDataNode.getRegion(), clientProfile);
+            CreateTopicRequest req = new CreateTopicRequest();
+            String[] allTags = tencentClsSinkDTO.getTag().split("\\|");
+            Tag[] tags = convertTags(allTags);
+            req.setTags(tags);
+            req.setLogsetId(tencentClsDataNode.getLogSetID());
+            req.setTopicName(tencentClsSinkDTO.getTopicName());
+            CreateTopicResponse resp = client.CreateTopic(req);
+            LOG.info("create cls topic {} success ,topicId {}", 
tencentClsSinkDTO.getTopicName(), resp.getTopicId());
+            tencentClsSinkDTO.setTopicID(resp.getTopicId());
+            sinkInfo.setExtParams(JsonUtils.toJsonString(tencentClsSinkDTO));
+            StreamSinkEntity streamSinkEntity = new StreamSinkEntity();
+            CommonBeanUtils.copyProperties(sinkInfo, streamSinkEntity, true);
+            streamSinkEntityMapper.updateByIdSelective(streamSinkEntity);
+            String info = "success to create cls resource";
+            sinkService.updateStatus(sinkInfo.getId(), 
SinkStatus.CONFIG_SUCCESSFUL.getCode(), info);
+            LOG.info("update cls sink info status {} success ,topicId {}", 
tencentClsSinkDTO.getTopicName(),

Review Comment:
   topicName



##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/node/cls/TencentClsDataNodeRequest.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.manager.pojo.node.cls;
+
+import org.apache.inlong.manager.common.consts.DataNodeType;
+import org.apache.inlong.manager.common.util.JsonTypeDefine;
+import org.apache.inlong.manager.pojo.node.DataNodeRequest;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+/**
+ * Tencent cloud log service data node request
+ */
+@Data
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeDefine(value = DataNodeType.CLS)
+@ApiModel("Tencent cloud log service data node request")
+public class TencentClsDataNodeRequest extends DataNodeRequest {
+
+    /**
+     *Tencent cloud log service master account
+     */
+    private String mainAccountID;

Review Comment:
   Please add ` @ApiModelProperty`



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/cls/TencentClsResourceOperator.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.manager.service.resource.sink.cls;
+
+import org.apache.inlong.manager.common.consts.DataNodeType;
+import org.apache.inlong.manager.common.consts.InlongConstants;
+import org.apache.inlong.manager.common.consts.SinkType;
+import org.apache.inlong.manager.common.enums.SinkStatus;
+import org.apache.inlong.manager.common.exceptions.WorkflowException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.apache.inlong.manager.dao.entity.DataNodeEntity;
+import org.apache.inlong.manager.dao.entity.StreamSinkEntity;
+import org.apache.inlong.manager.dao.mapper.DataNodeEntityMapper;
+import org.apache.inlong.manager.dao.mapper.StreamSinkEntityMapper;
+import org.apache.inlong.manager.pojo.node.cls.TencentClsDataNodeDTO;
+import org.apache.inlong.manager.pojo.sink.SinkInfo;
+import org.apache.inlong.manager.pojo.sink.cls.TencentClsSinkDTO;
+import org.apache.inlong.manager.service.resource.sink.SinkResourceOperator;
+import org.apache.inlong.manager.service.sink.StreamSinkService;
+
+import com.tencentcloudapi.cls.v20201016.ClsClient;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicRequest;
+import com.tencentcloudapi.cls.v20201016.models.CreateTopicResponse;
+import com.tencentcloudapi.cls.v20201016.models.Tag;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TencentClsResourceOperator implements SinkResourceOperator {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(TencentClsResourceOperator.class);
+
+    @Autowired
+    private DataNodeEntityMapper dataNodeEntityMapper;
+    @Autowired
+    private StreamSinkService sinkService;
+    @Autowired
+    private StreamSinkEntityMapper streamSinkEntityMapper;
+
+    @Override
+    public Boolean accept(String sinkType) {
+        return SinkType.CLS.equals(sinkType);
+    }
+
+    @Override
+    public void createSinkResource(SinkInfo sinkInfo) {
+        LOG.info("begin to create sink resources sinkId={}", sinkInfo.getId());
+        if 
(SinkStatus.CONFIG_SUCCESSFUL.getCode().equals(sinkInfo.getStatus())) {
+            LOG.warn("sink resource [" + sinkInfo.getId() + "] already 
success, skip to create");
+            return;
+        } else if 
(InlongConstants.DISABLE_CREATE_RESOURCE.equals(sinkInfo.getEnableCreateResource()))
 {
+            LOG.warn("create resource was disabled, skip to create for [" + 
sinkInfo.getId() + "]");
+            return;
+        }
+        this.createTopicID(sinkInfo);
+    }
+
+    private void createTopicID(SinkInfo sinkInfo) {
+        TencentClsDataNodeDTO tencentClsDataNode = 
getTencentClsDataNode(sinkInfo);
+        TencentClsSinkDTO tencentClsSinkDTO = 
JsonUtils.parseObject(sinkInfo.getExtParams(), TencentClsSinkDTO.class);
+        try {
+            Credential cred = new 
Credential(tencentClsDataNode.getManageSecretId(),
+                    tencentClsDataNode.getManageSecretId());
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint(tencentClsDataNode.getEndpoint());
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            ClsClient client = new ClsClient(cred, 
tencentClsDataNode.getRegion(), clientProfile);
+            CreateTopicRequest req = new CreateTopicRequest();
+            String[] allTags = tencentClsSinkDTO.getTag().split("\\|");

Review Comment:
   Please add to  `InlongConstanst`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to