You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "fuweng11 (via GitHub)" <gi...@apache.org> on 2024/06/12 02:07:06 UTC

[PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

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

   
   
   <!-- Prepare a Pull Request
   Change the title of pull request refer to the following example:
     [INLONG-XYZ][Component] Title of the pull request 
   -->
   
   <!-- Specify the issue this pull request going to fix.
   The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)-->
   
   Fixes #10391
   
   ### Motivation
   
    Supports configuring zk clusters and issuing zk addresses to agents.
   
   ### Modifications
   
    Supports configuring zk clusters and issuing zk addresses to agents.
   


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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "dockerzhang (via GitHub)" <gi...@apache.org>.
dockerzhang merged PR #10392:
URL: https://github.com/apache/inlong/pull/10392


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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "justinwwhuang (via GitHub)" <gi...@apache.org>.
justinwwhuang commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635881137


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -322,6 +328,34 @@ private void updateTaskStatus(CommandEntity command) {
         }
     }
 
+    @Override
+    public AgentConfigInfo getAgentConfig(AgentConfigRequest request) {
+        LOGGER.info("begin to get agent config info for {}", request);

Review Comment:
   Will there be too many logs printed like this?



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/AgentZkClusterOperator.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+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.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterDTO;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class AgentZkClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AgentZkClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return getClusterType().equals(clusterType);
+    }
+
+    @Override
+    public String getClusterType() {
+        return ClusterType.AGENT_ZK;
+    }
+
+    @Override
+    protected void setTargetEntity(ClusterRequest request, InlongClusterEntity targetEntity) {
+        AgentZkClusterRequest agentZkClusterRequest = (AgentZkClusterRequest) request;
+        CommonBeanUtils.copyProperties(agentZkClusterRequest, targetEntity, true);
+        try {
+            AgentZkClusterDTO dto =
+                    AgentZkClusterDTO.getFromRequest(agentZkClusterRequest, targetEntity.getExtParams());
+            targetEntity.setExtParams(objectMapper.writeValueAsString(dto));
+        } catch (Exception e) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_INFO_INCORRECT,
+                    String.format("serialize extParams of agent zk Cluster failure: %s", e.getMessage()));
+        }
+    }
+
+    @Override
+    public ClusterInfo getFromEntity(InlongClusterEntity entity) {
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
+        }
+        AgentZkClusterInfo info = new AgentZkClusterInfo();
+        CommonBeanUtils.copyProperties(entity, info);
+        if (StringUtils.isNotBlank(entity.getExtParams())) {
+            AgentZkClusterDTO dto = AgentZkClusterDTO.getFromJson(entity.getExtParams());
+            CommonBeanUtils.copyProperties(dto, info);
+        }
+        return info;
+    }
+
+    @Override
+    public Object getClusterInfo(InlongClusterEntity entity) {
+        AgentZkClusterInfo agentZkClusterInfo = (AgentZkClusterInfo) this.getFromEntity(entity);
+        Map<String, String> map = new HashMap<>();
+        map.put("url", agentZkClusterInfo.getUrl());

Review Comment:
   url should be defined using macros?



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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635732756


##########
inlong-common/src/main/java/org/apache/inlong/common/pojo/agent/AgentConfigRequest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.common.pojo.agent;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Request for Agent config
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AgentConfigRequest {
+
+    private String clusterTag;
+
+    private String clusterName;
+
+    private String ip;

Review Comment:
   what this field for?



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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635734536


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -322,6 +328,34 @@ private void updateTaskStatus(CommandEntity command) {
         }
     }
 
+    @Override
+    public AgentConfigInfo getAgentConfig(AgentConfigRequest request) {
+        LOGGER.info("begin to get init info for: " + request);

Review Comment:
   Fixed.



##########
inlong-common/src/main/java/org/apache/inlong/common/pojo/agent/AgentConfigRequest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.common.pojo.agent;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Request for Agent config
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AgentConfigRequest {
+
+    private String clusterTag;
+
+    private String clusterName;
+
+    private String ip;

Review Comment:
   Fixed.



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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635732756


##########
inlong-common/src/main/java/org/apache/inlong/common/pojo/agent/AgentConfigRequest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.common.pojo.agent;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Request for Agent config
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AgentConfigRequest {
+
+    private String clusterTag;
+
+    private String clusterName;
+
+    private String ip;

Review Comment:
   what's this field for?



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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635728005


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/zk/AgentZkClusterDTO.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.zk;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Agent zk cluster info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@ApiModel("Agent zk cluster info")
+public class AgentZkClusterDTO {
+
+    /**
+     * Get the dto instance from the request
+     */
+    public static AgentZkClusterDTO getFromRequest(AgentZkClusterRequest request) {
+        return AgentZkClusterDTO.builder()
+                .build();

Review Comment:
   Plz keep the logic consistent with the descriptions of docs `Get the dto instance from the 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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635730490


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/zk/AgentZkClusterDTO.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.zk;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Agent zk cluster info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@ApiModel("Agent zk cluster info")
+public class AgentZkClusterDTO {
+
+    /**
+     * Get the dto instance from the request
+     */
+    public static AgentZkClusterDTO getFromRequest(AgentZkClusterRequest request) {
+        return AgentZkClusterDTO.builder()
+                .build();

Review Comment:
   Fixed.



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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1635733592


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -322,6 +328,34 @@ private void updateTaskStatus(CommandEntity command) {
         }
     }
 
+    @Override
+    public AgentConfigInfo getAgentConfig(AgentConfigRequest request) {
+        LOGGER.info("begin to get init info for: " + request);

Review Comment:
   ```suggestion
           LOGGER.info("begin to get init info for {}", 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


Re: [PR] [INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents [inlong]

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10392:
URL: https://github.com/apache/inlong/pull/10392#discussion_r1637364960


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/AgentZkClusterOperator.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+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.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterDTO;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.zk.AgentZkClusterRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class AgentZkClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AgentZkClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return getClusterType().equals(clusterType);
+    }
+
+    @Override
+    public String getClusterType() {
+        return ClusterType.AGENT_ZK;
+    }
+
+    @Override
+    protected void setTargetEntity(ClusterRequest request, InlongClusterEntity targetEntity) {
+        AgentZkClusterRequest agentZkClusterRequest = (AgentZkClusterRequest) request;
+        CommonBeanUtils.copyProperties(agentZkClusterRequest, targetEntity, true);
+        try {
+            AgentZkClusterDTO dto =
+                    AgentZkClusterDTO.getFromRequest(agentZkClusterRequest, targetEntity.getExtParams());
+            targetEntity.setExtParams(objectMapper.writeValueAsString(dto));
+        } catch (Exception e) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_INFO_INCORRECT,
+                    String.format("serialize extParams of agent zk Cluster failure: %s", e.getMessage()));
+        }
+    }
+
+    @Override
+    public ClusterInfo getFromEntity(InlongClusterEntity entity) {
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
+        }
+        AgentZkClusterInfo info = new AgentZkClusterInfo();
+        CommonBeanUtils.copyProperties(entity, info);
+        if (StringUtils.isNotBlank(entity.getExtParams())) {
+            AgentZkClusterDTO dto = AgentZkClusterDTO.getFromJson(entity.getExtParams());
+            CommonBeanUtils.copyProperties(dto, info);
+        }
+        return info;
+    }
+
+    @Override
+    public Object getClusterInfo(InlongClusterEntity entity) {
+        AgentZkClusterInfo agentZkClusterInfo = (AgentZkClusterInfo) this.getFromEntity(entity);
+        Map<String, String> map = new HashMap<>();
+        map.put("url", agentZkClusterInfo.getUrl());

Review Comment:
   Here is a return map that supports extensions.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -322,6 +328,34 @@ private void updateTaskStatus(CommandEntity command) {
         }
     }
 
+    @Override
+    public AgentConfigInfo getAgentConfig(AgentConfigRequest request) {
+        LOGGER.info("begin to get agent config info for {}", request);

Review Comment:
   Fixed.



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