Skip to content

Commit

Permalink
[INLONG-10200][Manager] Define module type mapping relationships (#10203
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fuweng11 authored May 13, 2024
1 parent bbd29d9 commit cdf81cd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,34 @@

package org.apache.inlong.manager.common.enums;

import java.util.Objects;

/**
* Constant of module type.
*/
public enum ModuleType {

AGENT,
INSTALLER
AGENT(1),
INSTALLER(2),
UNKNOWN(3);

final int moduleId;

ModuleType(int moduleId) {
this.moduleId = moduleId;
}

public int getModuleId() {
return moduleId;
}

public static ModuleType forType(String type) {
for (ModuleType moduleType : ModuleType.values()) {
if (Objects.equals(moduleType.name(), type)) {
return moduleType;
}
}
return UNKNOWN;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
Expand Down Expand Up @@ -163,9 +162,6 @@ public class AgentServiceImpl implements AgentService {
@Value("${add.task.retention.days:7}")
private Integer retentionDays;

@Value("#{${module.name.map:{'agent':1}}}")
private Map<String, Integer> moduleNameIdMap = new HashMap<>();

@Autowired
private StreamSourceEntityMapper sourceMapper;
@Autowired
Expand Down Expand Up @@ -860,7 +856,7 @@ private List<ModuleConfig> getModuleConfigs(AgentClusterNodeDTO dto) {
for (Integer moduleId : moduleIdList) {
ModuleConfigEntity moduleConfigEntity = moduleConfigEntityMapper.selectByPrimaryKey(moduleId);
ModuleConfig moduleConfig = CommonBeanUtils.copyProperties(moduleConfigEntity, ModuleConfig::new);
moduleConfig.setId(moduleNameIdMap.getOrDefault(moduleConfigEntity.getName(), 1));
moduleConfig.setId(ModuleType.forType(moduleConfigEntity.getType()).getModuleId());
PackageConfigEntity packageConfigEntity =
packageConfigEntityMapper.selectByPrimaryKey(moduleConfigEntity.getPackageId());
moduleConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,4 @@ metrics.audit.proxy.hosts=127.0.0.1:10081
# tencent cloud log service endpoint, The Operator cls resource by it
cls.manager.endpoint=127.0.0.1

# The mapping relationship between module name and module id
module.name.map={'inlong-agent':1,'agent-installer':2,'temp-cmd':3}

Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,3 @@ metrics.audit.proxy.hosts=127.0.0.1:10081
# tencent cloud log service endpoint, The Operator cls resource by it
cls.manager.endpoint=127.0.0.1

# The mapping relationship between module name and module id
module.name.map={'inlong-agent':1,'agent-installer':2,'temp-cmd':3}
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,3 @@ metrics.audit.proxy.hosts=127.0.0.1:10081
# tencent cloud log service endpoint, The Operator cls resource by it
cls.manager.endpoint=127.0.0.1

# The mapping relationship between module name and module id
module.name.map={'inlong-agent':1,'agent-installer':2,'temp-cmd':3}

0 comments on commit cdf81cd

Please sign in to comment.