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