-
Notifications
You must be signed in to change notification settings - Fork 566
[INLONG-10391][Manager] Supports configuring zk clusters and issuing zk addresses to agents #10392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
160e8ca
[INLONG-10391][Manager] Supports configuring zk clusters and issuing …
fuweng11 d2f133b
[INLONG-10391][Manager] keep the logic consistent with the descriptio…
fuweng11 8a93444
[INLONG-10391][Manager] Remove useless parameters
fuweng11 a781571
[INLONG-10391][Manager] Modify log level
fuweng11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
inlong-common/src/main/java/org/apache/inlong/common/pojo/agent/AgentConfigInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.common.pojo.agent; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * The Agent config info. | ||
| */ | ||
| @Data | ||
| public class AgentConfigInfo { | ||
|
|
||
| private String zkUrl; | ||
|
|
||
| private AgentClusterInfo cluster; | ||
|
|
||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public static class AgentClusterInfo { | ||
|
|
||
| private Integer parentId; | ||
|
|
||
| private String clusterName; | ||
|
|
||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
inlong-common/src/main/java/org/apache/inlong/common/pojo/agent/AgentConfigRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...nager-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/zk/AgentZkClusterDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * 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.CommonBeanUtils; | ||
| import org.apache.inlong.manager.common.util.JsonUtils; | ||
|
|
||
| import io.swagger.annotations.ApiModel; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| 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, String extParams) { | ||
| AgentZkClusterDTO dto = StringUtils.isNotBlank(extParams) | ||
| ? AgentZkClusterDTO.getFromJson(extParams) | ||
| : new AgentZkClusterDTO(); | ||
| return CommonBeanUtils.copyProperties(request, dto, true); | ||
| } | ||
|
|
||
| /** | ||
| * Get the dto instance from the JSON string. | ||
| */ | ||
| public static AgentZkClusterDTO getFromJson(@NotNull String extParams) { | ||
| try { | ||
| return JsonUtils.parseObject(extParams, AgentZkClusterDTO.class); | ||
| } catch (Exception e) { | ||
| throw new BusinessException(ErrorCodeEnum.CLUSTER_INFO_INCORRECT, | ||
| String.format("parse extParams of agent zk Cluster failure: %s", e.getMessage())); | ||
| } | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ager-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/zk/AgentZkClusterInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * 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.ClusterType; | ||
| import org.apache.inlong.manager.common.util.CommonBeanUtils; | ||
| import org.apache.inlong.manager.common.util.JsonTypeDefine; | ||
| import org.apache.inlong.manager.pojo.cluster.ClusterInfo; | ||
|
|
||
| import io.swagger.annotations.ApiModel; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.ToString; | ||
|
|
||
| /** | ||
| * Inlong cluster info for agent ZK | ||
| */ | ||
| @Data | ||
| @ToString(callSuper = true) | ||
| @EqualsAndHashCode(callSuper = true) | ||
| @JsonTypeDefine(value = ClusterType.AGENT_ZK) | ||
| @ApiModel("Inlong cluster info for agent ZK") | ||
| public class AgentZkClusterInfo extends ClusterInfo { | ||
|
|
||
| public AgentZkClusterInfo() { | ||
| this.setType(ClusterType.AGENT_ZK); | ||
| } | ||
|
|
||
| @Override | ||
| public AgentZkClusterRequest genRequest() { | ||
| return CommonBeanUtils.copyProperties(this, AgentZkClusterRequest::new); | ||
| } | ||
|
|
||
| } |
43 changes: 43 additions & 0 deletions
43
...r-pojo/src/main/java/org/apache/inlong/manager/pojo/cluster/zk/AgentZkClusterRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * 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.ClusterType; | ||
| import org.apache.inlong.manager.common.util.JsonTypeDefine; | ||
| import org.apache.inlong.manager.pojo.cluster.ClusterRequest; | ||
|
|
||
| import io.swagger.annotations.ApiModel; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.ToString; | ||
|
|
||
| /** | ||
| * Inlong cluster request for agent ZK | ||
| */ | ||
| @Data | ||
| @ToString(callSuper = true) | ||
| @EqualsAndHashCode(callSuper = true) | ||
| @JsonTypeDefine(value = ClusterType.AGENT_ZK) | ||
| @ApiModel("Inlong cluster request for agent ZK") | ||
| public class AgentZkClusterRequest extends ClusterRequest { | ||
|
|
||
| public AgentZkClusterRequest() { | ||
| this.setType(ClusterType.AGENT_ZK); | ||
| } | ||
|
|
||
| } |
94 changes: 94 additions & 0 deletions
94
...rvice/src/main/java/org/apache/inlong/manager/service/cluster/AgentZkClusterOperator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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()); | ||
| return map; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.