use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.
the class CmTemplateProcessor method removeDanglingVariableReferences.
private List<ApiClusterTemplateConfig> removeDanglingVariableReferences(List<ApiClusterTemplateConfig> configs, Set<String> existingVariables, String refName) {
if (configs != null) {
for (Iterator<ApiClusterTemplateConfig> iter = configs.iterator(); iter.hasNext(); ) {
ApiClusterTemplateConfig config = iter.next();
String variable = config.getVariable();
if (variable != null && !existingVariables.contains(variable)) {
LOGGER.info("Removed dangling variable reference '{}': '{}' from section {}", config.getName(), variable, refName);
iter.remove();
}
}
if (configs.isEmpty()) {
return null;
}
}
return configs;
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.
the class CmTemplateProcessor method getCustomServiceConfigsMap.
public Map<String, List<ApiClusterTemplateConfig>> getCustomServiceConfigsMap(Set<CustomConfigurationPropertyView> configProperties) {
Map<String, List<ApiClusterTemplateConfig>> serviceConfigsMap = new HashMap<>();
List<CustomConfigurationPropertyView> serviceConfigs = getCustomServiceConfigs(configProperties);
serviceConfigs.forEach(serviceConfig -> {
serviceConfigsMap.computeIfAbsent(serviceConfig.getServiceType(), k -> new ArrayList<>());
serviceConfigsMap.get(serviceConfig.getServiceType()).add(new ApiClusterTemplateConfig().name(serviceConfig.getName()).value(serviceConfig.getValue()));
});
return serviceConfigsMap;
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.
the class CmTemplateProcessor method chooseApiClusterTemplateConfig.
private void chooseApiClusterTemplateConfig(Map<String, ApiClusterTemplateConfig> existingConfigs, ApiClusterTemplateConfig newConfig) {
String configName = newConfig.getName();
ApiClusterTemplateConfig existingApiClusterTemplateConfig = existingConfigs.get(configName);
if (existingApiClusterTemplateConfig != null) {
// OPSAPS-54706 Let's honor the safety valve settings in both bp and generated.
if (configName.endsWith("_safety_valve")) {
String oldConfigValue = existingApiClusterTemplateConfig.getValue();
String newConfigValue = newConfig.getValue();
// By CB-1452 append the bp config at the end of generated config to give precedence to it. Add a newline in between for it to be safe
// with property file safety valves and command line safety valves.
newConfig.setValue(newConfigValue + '\n' + oldConfigValue);
} else {
// Again by CB-1452 we need to give precedence to the value given in bp.
return;
}
}
existingConfigs.put(configName, newConfig);
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.
the class CmTemplateProcessor method addRoleConfigs.
public void addRoleConfigs(String serviceType, Map<String, List<ApiClusterTemplateConfig>> newConfigMap) {
Optional<ApiClusterTemplateService> serviceOpt = getServiceByType(serviceType);
if (serviceOpt.isPresent()) {
ApiClusterTemplateService service = serviceOpt.get();
newConfigMap.forEach((configRef, newConfigs) -> service.getRoleConfigGroups().stream().filter(rcg -> rcg.getRefName().equals(configRef)).findFirst().ifPresent(group -> mergeRoleConfigs(group, newConfigs)));
}
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.
the class CmHostGroupRoleConfigProviderProcessor method groupByHostGroupName.
private void groupByHostGroupName(TemplatePreparationObject source, Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup, Map<String, ServiceComponent> serviceComponents, String hostGroupName, List<String> roleConfigGroups, HostgroupView hostgroupView) {
for (String roleConfigGroup : roleConfigGroups) {
for (CmHostGroupRoleConfigProvider provider : providers) {
ServiceComponent serviceComponent = serviceComponents.get(roleConfigGroup);
if (isServiceComponentEquals(provider, serviceComponent)) {
Map<String, List<ApiClusterTemplateConfig>> configs = configsByRoleConfigGroup.computeIfAbsent(roleConfigGroup, __ -> new HashMap<>());
configs.computeIfAbsent(hostGroupName, __ -> new ArrayList<>()).addAll(provider.getRoleConfigs(serviceComponent.getComponent(), hostgroupView, source));
}
}
}
}
Aggregations