Search in sources :

Example 6 with ServiceConfig

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;
}
Also used : ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArrayList(java.util.ArrayList) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) HashSet(java.util.HashSet)

Aggregations

ServiceConfig (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig)6 HashSet (java.util.HashSet)6 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)2 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)2 CdhService (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.CdhService)2 SupportedService (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService)2 SupportedServices (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices)2 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)1 StackVersion (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)1 ServiceDependencies (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceDependencies)1 Dependencies (com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.Dependencies)1 ServiceDependencyMatrix (com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.ServiceDependencyMatrix)1 Services (com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.Services)1 SupportedVersion (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersion)1 SupportedVersions (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersions)1 GeneratedCmTemplate (com.sequenceiq.cloudbreak.cmtemplate.generator.template.domain.GeneratedCmTemplate)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1