Search in sources :

Example 1 with StackVersion

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

the class DeclaredVersionService method fallbackForDefault.

public Set<CdhService> fallbackForDefault() {
    StackVersion stackVersion = new StackVersion();
    stackVersion.setVersion("default");
    stackVersion.setStackType("CDH");
    return cmTemplateGeneratorConfigurationResolver.cdhConfigurations().get(stackVersion);
}
Also used : StackVersion(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)

Example 2 with StackVersion

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

the class CmTemplateGeneratorConfigurationResolver method readAllFilesFromParameterDir.

private Map<StackVersion, Set<CdhService>> readAllFilesFromParameterDir() {
    Map<StackVersion, Set<CdhService>> collectedFiles = new HashMap<>();
    try {
        List<Resource> files = getFiles(cdhConfigurationsPath);
        for (Resource serviceEntry : files) {
            String[] serviceAndPath = serviceEntry.getURL().getPath().split(cdhConfigurationsPath);
            String cdhVersion = serviceAndPath[1].split("/")[1].replace(".json", "");
            String insideFolder = String.format("%s%s", cdhConfigurationsPath, serviceAndPath[1]);
            LOGGER.debug("The entry url: {} file url: {} for version: {}", serviceEntry, insideFolder, cdhVersion);
            String content = readFileFromClasspathQuietly(insideFolder);
            ServiceList serviceList = MAPPER.readValue(content, ServiceList.class);
            StackVersion stackVersion = new StackVersion();
            stackVersion.setStackType(serviceList.getStackType());
            stackVersion.setVersion(serviceList.getVersion());
            collectedFiles.put(stackVersion, serviceList.getServices());
        }
    } catch (IOException ex) {
        String message = String.format("Could not read files from folder: %s", cdhConfigurationsPath);
        LOGGER.error(message, ex);
    }
    return collectedFiles;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ServiceList(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.ServiceList) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) StackVersion(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)

Example 3 with StackVersion

use of com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion 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

StackVersion (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)3 HashSet (java.util.HashSet)2 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)1 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 ServiceConfig (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig)1 CdhService (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.CdhService)1 ServiceList (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.ServiceList)1 SupportedService (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService)1 SupportedServices (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 Resource (org.springframework.core.io.Resource)1