use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.
the class GeneratedCmTemplateService method prepareApiClusterTemplateServices.
private List<ApiClusterTemplateService> prepareApiClusterTemplateServices(Set<ServiceConfig> serviceConfigs, Map<String, Set<String>> hostServiceMap) {
List<ApiClusterTemplateService> clusterTemplateServices = new ArrayList<>();
for (ServiceConfig serviceConfig : serviceConfigs) {
String serviceName = serviceConfig.getName();
String lowerCaseServiceName = serviceName.toLowerCase();
ApiClusterTemplateService apiClusterTemplateService = new ApiClusterTemplateService();
apiClusterTemplateService.setRefName(lowerCaseServiceName);
apiClusterTemplateService.setServiceType(serviceName);
apiClusterTemplateService.setRoleConfigGroups(new ArrayList<>());
serviceConfig.getComponents().forEach(component -> {
Set<ApiClusterTemplateRoleConfigGroup> roleConfigGroups = new HashSet<>();
component.getGroups().forEach(group -> {
String componentName = component.getName();
boolean base = component.getGroups().size() == 1 || component.isBase();
String hostServiceNameEnd = base ? "BASE" : group.toUpperCase();
String hostServiceName = String.format("%s-%s-%s", lowerCaseServiceName, component.getName().toUpperCase(), hostServiceNameEnd);
ApiClusterTemplateRoleConfigGroup apiClusterTemplateRoleConfigGroup = new ApiClusterTemplateRoleConfigGroup();
apiClusterTemplateRoleConfigGroup.setRoleType(componentName.toUpperCase());
apiClusterTemplateRoleConfigGroup.setRefName(hostServiceName);
apiClusterTemplateRoleConfigGroup.setBase(base);
if (hostServiceMap.keySet().contains(group)) {
hostServiceMap.get(group).add(hostServiceName);
} else {
hostServiceMap.put(group, Sets.newHashSet(hostServiceName));
}
roleConfigGroups.add(apiClusterTemplateRoleConfigGroup);
});
apiClusterTemplateService.getRoleConfigGroups().addAll(roleConfigGroups);
});
clusterTemplateServices.add(apiClusterTemplateService);
}
return clusterTemplateServices;
}
Aggregations