Search in sources :

Example 1 with ServiceConfig

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.

the class SupportedVersionService method collectSupportedVersions.

public SupportedVersions collectSupportedVersions() {
    SupportedVersions supportedVersions = new SupportedVersions();
    Set<SupportedVersion> supportedVersionsSet = new HashSet<>();
    resolver.cdhConfigurations().forEach((key, value) -> {
        SupportedVersion supportedVersion = new SupportedVersion();
        supportedVersion.setType(key.getStackType());
        supportedVersion.setVersion(key.getVersion());
        SupportedServices supportedServices = new SupportedServices();
        for (CdhService serviceName : value) {
            for (ServiceConfig serviceInformation : resolver.serviceConfigs()) {
                if (serviceInformation.getName().equals(serviceName.getName())) {
                    SupportedService supportedService = new SupportedService();
                    supportedService.setName(serviceInformation.getName());
                    supportedService.setDisplayName(serviceInformation.getDisplayName());
                    supportedService.setVersion(serviceName.getVersion());
                    supportedServices.getServices().add(supportedService);
                    break;
                }
            }
        }
        supportedVersion.setSupportedServices(supportedServices);
        supportedVersionsSet.add(supportedVersion);
    });
    supportedVersions.setSupportedVersions(supportedVersionsSet);
    return supportedVersions;
}
Also used : SupportedService(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService) CdhService(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.CdhService) ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) SupportedVersions(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersions) SupportedServices(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices) SupportedVersion(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersion) HashSet(java.util.HashSet)

Example 2 with ServiceConfig

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.

the class GeneratedCmTemplateService method prepareClouderaManagerTemplate.

public GeneratedCmTemplate prepareClouderaManagerTemplate(Set<String> services, String stackType, String version, String uuid) {
    CmTemplateProcessor processor = initiateTemplate();
    Set<ServiceConfig> serviceConfigs = collectServiceConfigs(services);
    Map<String, Set<String>> hostServiceMap = new HashMap<>();
    prepareCdhVersion(stackType, version, processor);
    processor.setDisplayName(prepareDisplayName(uuid));
    processor.setServices(prepareApiClusterTemplateServices(serviceConfigs, hostServiceMap));
    processor.setHostTemplates(prepareApiClusterTemplateHostTemplates(hostServiceMap));
    return new GeneratedCmTemplate(prepareTemplate(processor));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) HashMap(java.util.HashMap) GeneratedCmTemplate(com.sequenceiq.cloudbreak.cmtemplate.generator.template.domain.GeneratedCmTemplate) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Example 3 with ServiceConfig

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.

the class CmTemplateGeneratorConfigurationResolver method readServiceDefinitions.

private Set<ServiceConfig> readServiceDefinitions() {
    Set<ServiceConfig> serviceConfigs = new HashSet<>();
    String content = readFileFromClasspathQuietly(serviceDefinitionConfigurationPath);
    try {
        ServiceDependencies serviceDependencies = MAPPER.readValue(content, ServiceDependencies.class);
        serviceConfigs = serviceDependencies.getServices();
    } catch (IOException ex) {
        String message = String.format("Could not read service definitions from: %s", serviceDefinitionConfigurationPath);
        LOGGER.error(message, ex);
    }
    return serviceConfigs;
}
Also used : ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) ServiceDependencies(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceDependencies) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 4 with ServiceConfig

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.

the class ServiceDependencyMatrixService method collectServiceDependencyMatrix.

public ServiceDependencyMatrix collectServiceDependencyMatrix(Set<String> services, String stackType, String version) {
    ServiceDependencyMatrix serviceDependencyMatrix = new ServiceDependencyMatrix();
    Services servicesObject = new Services();
    servicesObject.setServices(services);
    serviceDependencyMatrix.setServices(servicesObject);
    Dependencies dependencies = new Dependencies();
    Set<String> deps = new HashSet<>();
    for (String service : services) {
        for (ServiceConfig serviceInformation : resolver.serviceConfigs()) {
            if (service.toUpperCase().equals(serviceInformation.getName())) {
                for (String dependency : serviceInformation.getDependencies()) {
                    deps.add(dependency.toUpperCase());
                }
                break;
            }
        }
    }
    dependencies.setServices(deps);
    serviceDependencyMatrix.setDependencies(dependencies);
    return serviceDependencyMatrix;
}
Also used : Services(com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.Services) ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) Dependencies(com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.Dependencies) ServiceDependencyMatrix(com.sequenceiq.cloudbreak.cmtemplate.generator.dependencies.domain.ServiceDependencyMatrix) HashSet(java.util.HashSet)

Example 5 with ServiceConfig

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig in project cloudbreak by hortonworks.

the class DeclaredVersionService method collectDeclaredVersions.

public SupportedServices collectDeclaredVersions(String blueprintText) {
    SupportedServices supportedServices = new SupportedServices();
    Set<SupportedService> services = new HashSet<>();
    CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(blueprintText);
    String cdhVersion = cmTemplateProcessor.getTemplate().getCdhVersion();
    StackVersion stackVersion = new StackVersion();
    stackVersion.setVersion(cdhVersion);
    stackVersion.setStackType("CDH");
    Set<CdhService> cdhServices = cmTemplateGeneratorConfigurationResolver.cdhConfigurations().get(stackVersion);
    if (cdhServices == null) {
        cdhServices = fallbackForDefault();
    }
    for (ApiClusterTemplateService service : cmTemplateProcessor.getTemplate().getServices()) {
        SupportedService supportedService = new SupportedService();
        supportedService.setName(service.getServiceType());
        for (CdhService cdhService : cdhServices) {
            if (cdhService.getName().equals(service.getServiceType())) {
                supportedService.setVersion(cdhService.getVersion());
            }
        }
        for (ServiceConfig serviceConfig : cmTemplateGeneratorConfigurationResolver.serviceConfigs()) {
            if (serviceConfig.getName().equals(service.getServiceType())) {
                supportedService.setDisplayName(serviceConfig.getDisplayName());
                supportedService.setComponentNameInParcel(serviceConfig.getComponentNameInParcel());
            }
        }
        if (!Strings.isNullOrEmpty(supportedService.getDisplayName()) && !Strings.isNullOrEmpty(supportedService.getVersion())) {
            services.add(supportedService);
        }
    }
    supportedServices.setServices(services);
    return supportedServices;
}
Also used : SupportedService(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService) CdhService(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.CdhService) ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) SupportedServices(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HashSet(java.util.HashSet) StackVersion(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)

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