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);
}
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;
}
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;
}
Aggregations