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/10 02:22:08 UTC

[GitHub] [inlong] fuweng11 opened a new pull request, #7200: [INLONG-7199][Manager] Support save extension params for inlong cluster node

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

   
   ### Prepare a Pull Request
   
   - Fixes #7199 
   
   ### Motivation
   
   Support save extension params for inlong cluster node
   
   ### Modifications
   
   Support save extension params for inlong cluster node
   


-- 
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 commented on a diff in pull request #7200: [INLONG-7199][Manager] Support save extension params for inlong cluster node

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/node/AgentClusterNodeOperator.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.cluster.node;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.enums.ClusterType;
+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.dao.entity.InlongClusterNodeEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeRequest;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeResponse;
+import org.apache.inlong.manager.pojo.cluster.agent.AgentClusterNodeDTO;
+import org.apache.inlong.manager.pojo.cluster.agent.AgentClusterNodeRequest;
+import org.apache.inlong.manager.pojo.cluster.agent.AgentClusterNodeResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Agent cluster node operator.
+ */
+@Slf4j
+@Service
+public class AgentClusterNodeOperator extends AbstractClusterNodeOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AgentClusterNodeOperator.class);
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public Boolean accept(String clusterNodeType) {
+        return getClusterNodeType().equals(clusterNodeType);
+    }
+
+    @Override
+    public String getClusterNodeType() {
+        return ClusterType.AGENT;
+    }
+
+    @Override
+    public ClusterNodeResponse getFromEntity(InlongClusterNodeEntity entity) {
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
+        }
+
+        AgentClusterNodeResponse agentClusterNodeResponse = new AgentClusterNodeResponse();
+        CommonBeanUtils.copyProperties(entity, agentClusterNodeResponse);
+        if (StringUtils.isNotBlank(entity.getExtParams())) {
+            AgentClusterNodeDTO dto = AgentClusterNodeDTO.getFromJson(entity.getExtParams());
+            CommonBeanUtils.copyProperties(dto, agentClusterNodeResponse);
+        }
+
+        LOGGER.debug("success to get agent cluster node info from entity");
+        return agentClusterNodeResponse;
+    }
+
+    @Override
+    protected void setTargetEntity(ClusterNodeRequest request, InlongClusterNodeEntity targetEntity) {
+        AgentClusterNodeRequest agentNodeRequest = (AgentClusterNodeRequest) request;
+        CommonBeanUtils.copyProperties(agentNodeRequest, targetEntity, true);
+        try {
+            AgentClusterNodeDTO dto = AgentClusterNodeDTO.getFromRequest(agentNodeRequest);
+            targetEntity.setExtParams(objectMapper.writeValueAsString(dto));
+            LOGGER.debug("success to set entity for agent cluster node");
+        } catch (Exception e) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_INFO_INCORRECT.getMessage() + ": " + e.getMessage());

Review Comment:
   need to carry the error code, not only error message



-- 
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 merged pull request #7200: [INLONG-7199][Manager] Support save extension params for inlong cluster node

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


-- 
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 #7200: [INLONG-7199][Manager] Support save extension params for inlong cluster node

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


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/agent/AgentClusterNodeResponse.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cluster.agent;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.util.JsonTypeDefine;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeResponse;
+
+/**
+ * Agent cluster response
+ */
+@Data
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeDefine(value = ClusterType.AGENT)
+@ApiModel("Inlong cluster node response for Agent")
+public class AgentClusterNodeResponse extends ClusterNodeResponse {
+
+    @ApiModelProperty(value = "Cluster agent grou")

Review Comment:
   "Cluster agent group" is weird, "Agent group name" is enough.
   
   ```suggestion
       @ApiModelProperty(value = "Agent group name")
   ```



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