Search in sources :

Example 16 with ApiClusterTemplateService

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

the class CmTemplateProcessorTest method testAddRoleConfigsWithNoMatchinRefName.

@Test
public void testAddRoleConfigsWithNoMatchinRefName() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    configs.put("hdfs-NAMENODE-nomatch", List.of(new ApiClusterTemplateConfig().name("dfs_name_dir_list").variable("master_NAMENODE")));
    configs.put("hdfs-DATANODE-nomatch", List.of(new ApiClusterTemplateConfig().name("dfs_data_dir_list").variable("worker_DATANODE")));
    underTest.addRoleConfigs("HDFS", configs);
    ApiClusterTemplateService service = underTest.getTemplate().getServices().stream().filter(srv -> "HDFS".equals(srv.getServiceType())).findAny().get();
    ApiClusterTemplateRoleConfigGroup dn = service.getRoleConfigGroups().stream().filter(rcg -> "DATANODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> dnConfigs = dn.getConfigs();
    ApiClusterTemplateRoleConfigGroup nn = service.getRoleConfigGroups().stream().filter(rcg -> "NAMENODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> nnConfigs = nn.getConfigs();
    assertNull(nnConfigs);
    assertNull(dnConfigs);
}
Also used : HashMap(java.util.HashMap) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 17 with ApiClusterTemplateService

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

the class CmTemplateProcessorTest method testIfCustomServiceConfigsAreMerged.

@Test
public void testIfCustomServiceConfigsAreMerged() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    // config not present in template
    List<ApiClusterTemplateConfig> sparkConfigs = List.of(new ApiClusterTemplateConfig().name("spark_drive_log_persist_to_dfs").value("false"));
    // config present in template
    List<ApiClusterTemplateConfig> hiveConfigs = List.of(new ApiClusterTemplateConfig().name("tez_auto_reducer_parallelism").value("true"), new ApiClusterTemplateConfig().name("hive_service_config_safety_valve").value("<property><name>hive_server2_tez_session_lifetime</name><value>30m</value></property>"));
    ApiClusterTemplateService spark = underTest.getTemplate().getServices().stream().filter(service -> "SPARK_ON_YARN".equals(service.getServiceType())).findFirst().get();
    ApiClusterTemplateService hive = underTest.getTemplate().getServices().stream().filter(service -> "HIVE_ON_TEZ".equals(service.getServiceType())).findFirst().get();
    List<ApiClusterTemplateConfig> existingSparkConfigs = spark.getServiceConfigs();
    List<ApiClusterTemplateConfig> existingHiveConfigs = hive.getServiceConfigs();
    underTest.mergeCustomServiceConfigs(spark, sparkConfigs);
    underTest.mergeCustomServiceConfigs(hive, hiveConfigs);
    assertEquals(spark.getServiceConfigs().size(), (existingSparkConfigs == null ? 0 : existingSparkConfigs.size()) + sparkConfigs.size());
    assertEquals(hive.getServiceConfigs().size(), existingHiveConfigs.size());
    assertTrue(existingHiveConfigs.get(2).getValue().endsWith("<property><name>hive_server2_tez_session_lifetime</name><value>30m</value></property>"));
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 18 with ApiClusterTemplateService

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

the class CentralCmTemplateUpdaterTest method configsAreInjected.

@Test
public void configsAreInjected() {
    List<ApiClusterTemplateConfig> serviceConfigs = List.of(config("service_config_name", "service_config_value"));
    List<ApiClusterTemplateConfig> roleConfigs = List.of(config("role_config_name", "role_config_value"));
    ReflectionTestUtils.setField(cmTemplateConfigInjectorProcessor, "injectors", List.of(new CmTemplateConfigInjector() {

        @Override
        public List<ApiClusterTemplateConfig> getServiceConfigs(ApiClusterTemplateService service, TemplatePreparationObject source) {
            return serviceConfigs;
        }

        @Override
        public List<ApiClusterTemplateConfig> getRoleConfigs(ApiClusterTemplateRoleConfigGroup roleConfigGroup, ApiClusterTemplateService service, TemplatePreparationObject source) {
            return roleConfigs;
        }
    }));
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/namenode-ha.bp"));
    ApiClusterTemplate generated = testGetCmTemplate();
    assertMatchesBlueprintAtPath("output/namenode-ha-injected.bp", generated);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.Test)

Example 19 with ApiClusterTemplateService

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

the class RangerRazBaseConfigProvider method createTemplate.

protected ApiClusterTemplateService createTemplate() {
    ApiClusterTemplateService coreSettings = new ApiClusterTemplateService().serviceType(RANGER_RAZ).refName("ranger-RANGER_RAZ");
    ApiClusterTemplateRoleConfigGroup coreSettingsRole = new ApiClusterTemplateRoleConfigGroup().roleType(RANGER_RAZ_SERVER).base(true).refName("ranger-RANGER_RAZ_SERVER");
    coreSettings.roleConfigGroups(List.of(coreSettingsRole));
    return coreSettings;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Example 20 with ApiClusterTemplateService

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

the class RangerRazDatahubConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source)) {
        ApiClusterTemplateService coreSettings = createTemplate();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        Map<String, Set<ServiceComponent>> serviceComponentsByHostGroup = cmTemplateProcessor.getServiceComponentsByHostGroup();
        Set<String> zkServerGroups = collectZKServers(serviceComponentsByHostGroup);
        boolean weHaveMoreThan2ZKServer = getZKHostNumbers(hostgroupViews, zkServerGroups);
        return hostgroupViews.stream().filter(hg -> isProperHostGroupForRaz(hg, zkServerGroups, weHaveMoreThan2ZKServer)).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) Set(java.util.Set) Collectors(java.util.stream.Collectors) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Component(org.springframework.stereotype.Component) Map(java.util.Map) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) Set(java.util.Set) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

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