Search in sources :

Example 1 with SupportedServices

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

use of com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices in project cloudbreak by hortonworks.

the class ParcelFilterServiceTest method testShouldReturnAllParcelsWhenTheServiceNamesInTheBlueprintContainsANullValue.

@Test
void testShouldReturnAllParcelsWhenTheServiceNamesInTheBlueprintContainsANullValue() {
    String parcelUrl = "http://parcel1.com/";
    String parcelName = "CUSTOM";
    ClouderaManagerProduct parcel = new ClouderaManagerProduct().withParcel(parcelUrl).withName(parcelName);
    SupportedService supportedService = new SupportedService();
    supportedService.setComponentNameInParcel(null);
    SupportedServices supportedServices = new SupportedServices();
    supportedServices.setServices(Set.of(supportedService));
    when(clusterTemplateGeneratorService.getServicesByBlueprint(BLUEPRINT_TEXT)).thenReturn(supportedServices);
    assertEquals(1, underTest.filterParcelsByBlueprint(STACK_ID, Set.of(parcel), getBlueprint()).size());
}
Also used : SupportedService(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService) SupportedServices(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with SupportedServices

use of com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices in project cloudbreak by hortonworks.

the class ParcelFilterServiceTest method getSupportedServices.

private SupportedServices getSupportedServices(Set<String> componentNames) {
    SupportedServices supportedServices = new SupportedServices();
    Set<SupportedService> services = componentNames.stream().map(s -> {
        SupportedService supportedService = new SupportedService();
        supportedService.setComponentNameInParcel(s);
        return supportedService;
    }).collect(Collectors.toSet());
    supportedServices.setServices(services);
    return supportedServices;
}
Also used : InjectMocks(org.mockito.InjectMocks) Arrays(java.util.Arrays) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) SupportedService(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService) Mock(org.mockito.Mock) Collection(java.util.Collection) SupportedServices(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices) Set(java.util.Set) CmTemplateGeneratorService(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateGeneratorService) ImageReaderService(com.sequenceiq.cloudbreak.service.upgrade.sync.component.ImageReaderService) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Test(org.junit.jupiter.api.Test) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LinkedHashSet(java.util.LinkedHashSet) MethodSource(org.junit.jupiter.params.provider.MethodSource) SupportedService(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService) SupportedServices(com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices)

Example 4 with SupportedServices

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

SupportedService (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedService)4 SupportedServices (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedServices)4 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ServiceConfig (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig)2 CdhService (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.versionmatrix.CdhService)2 HashSet (java.util.HashSet)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)1 CmTemplateGeneratorService (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateGeneratorService)1 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 StackVersion (com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.StackVersion)1 SupportedVersion (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersion)1 SupportedVersions (com.sequenceiq.cloudbreak.cmtemplate.generator.support.domain.SupportedVersions)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 ImageReaderService (com.sequenceiq.cloudbreak.service.upgrade.sync.component.ImageReaderService)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1