Search in sources :

Example 41 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class CmTemplateProcessorTest method addExistingServiceConfigs.

@Test
public void addExistingServiceConfigs() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-existing-conf.bp"));
    List<ApiClusterTemplateConfig> configs = new ArrayList<>();
    configs.add(new ApiClusterTemplateConfig().name("redaction_policy_enabled").value("true"));
    configs.add(new ApiClusterTemplateConfig().name("not_present_in_template").value("some_value"));
    underTest.addServiceConfigs("HDFS", List.of("NAMENODE"), configs);
    ApiClusterTemplateService service = underTest.getTemplate().getServices().stream().filter(srv -> "HDFS".equals(srv.getServiceType())).findAny().get();
    List<ApiClusterTemplateConfig> serviceConfigs = service.getServiceConfigs();
    assertEquals(2, serviceConfigs.size());
    assertEquals("redaction_policy_enabled", serviceConfigs.get(0).getName());
    assertEquals("false", serviceConfigs.get(0).getValue());
    assertEquals(configs.get(1), serviceConfigs.get(1));
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 42 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class HiveMetastoreConfigProviderTest method initHmsServiceConfigs.

private void initHmsServiceConfigs(List<ApiClusterTemplateConfig> serviceConfigs) {
    ApiClusterTemplateService service = new ApiClusterTemplateService();
    service.setServiceConfigs(serviceConfigs);
    when(templateProcessor.getServiceByType(HiveRoles.HIVE)).thenReturn(Optional.of(service));
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService)

Example 43 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenKnoxRequestedAndBlueprintDoesNoContainKnoxWithMultiGateway.

@Test
public void testGetAdditionalServicesWhenKnoxRequestedAndBlueprintDoesNoContainKnoxWithMultiGateway() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView master2 = new HostgroupView("master2", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    Gateway gateway = new Gateway();
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, master2, worker)).withGateway(gateway, "key", new HashSet<>()).build();
    String inputJson = getBlueprintText("input/clouderamanager.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, ApiClusterTemplateService> additionalServices = underTest.getAdditionalServices(cmTemplateProcessor, preparationObject);
    ApiClusterTemplateService knox1 = additionalServices.get("master");
    ApiClusterTemplateService knox2 = additionalServices.get("master2");
    assertEquals(2, additionalServices.size());
    assertNotNull(knox1);
    assertNotNull(knox2);
    assertEquals("KNOX", knox1.getServiceType());
    assertEquals("KNOX", knox2.getServiceType());
    assertEquals("knox", knox1.getRefName());
    assertEquals("knox", knox2.getRefName());
    ApiClusterTemplateRoleConfigGroup roleConfigGroup1 = knox1.getRoleConfigGroups().get(0);
    ApiClusterTemplateRoleConfigGroup roleConfigGroup2 = knox1.getRoleConfigGroups().get(0);
    assertEquals("KNOX_GATEWAY", roleConfigGroup1.getRoleType());
    assertTrue(roleConfigGroup1.getBase());
    assertEquals("KNOX_GATEWAY", roleConfigGroup2.getRoleType());
    assertTrue(roleConfigGroup2.getBase());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 44 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenKnoxRequestedAndBlueprintContainsIt.

@Test
public void testGetAdditionalServicesWhenKnoxRequestedAndBlueprintContainsIt() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    Gateway gateway = new Gateway();
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).withGateway(gateway, "key", new HashSet<>()).build();
    String inputJson = getBlueprintText("input/clouderamanager-knox.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, ApiClusterTemplateService> additionalServices = underTest.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertTrue(additionalServices.isEmpty());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 45 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService 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

ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)48 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)30 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)19 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)18 DisplayName (org.junit.jupiter.api.DisplayName)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)15 ArrayList (java.util.ArrayList)14 Test (org.junit.jupiter.api.Test)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 List (java.util.List)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Set (java.util.Set)9 Collectors (java.util.stream.Collectors)9 Optional (java.util.Optional)8