use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup in project cloudbreak by hortonworks.
the class CmTemplateProcessorTest method addExistingSafetyValveConfigs.
@Test
public void addExistingSafetyValveConfigs() {
underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-existing-conf.bp"));
List<ApiClusterTemplateConfig> configs = new ArrayList<>();
configs.add(new ApiClusterTemplateConfig().name("hive_service_config_safety_valve").value("<property><name>testkey</name><value>testvalue</value></property>"));
underTest.addServiceConfigs("HIVE", List.of("GATEWAY", "HIVEMETASTORE"), configs);
ApiClusterTemplateService service = underTest.getTemplate().getServices().stream().filter(srv -> "HIVE".equals(srv.getServiceType())).findAny().get();
List<ApiClusterTemplateConfig> serviceConfigs = service.getServiceConfigs();
assertEquals(1, serviceConfigs.size());
assertEquals("hive_service_config_safety_valve", serviceConfigs.get(0).getName());
assertTrue(serviceConfigs.get(0).getValue().startsWith("<property><name>testkey</name><value>testvalue</value></property>"));
assertTrue(serviceConfigs.get(0).getValue().endsWith("<property><name>hive.metastore.server.filter.enabled</name><value>true</value></property> " + "<property><name>hive.metastore.filter.hook</name>" + "<value>org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthorizer</value></property>"));
assertTrue(serviceConfigs.get(0).getValue().contains("\n"));
Map<String, List<ApiClusterTemplateConfig>> roleConfigs = new HashMap<>();
roleConfigs.put("spark_on_yarn-GATEWAY-BASE", List.of(new ApiClusterTemplateConfig().name("spark-conf/spark-defaults.conf_client_config_safety_valve").value("testkey=testvalue")));
underTest.addRoleConfigs("SPARK_ON_YARN", roleConfigs);
service = underTest.getTemplate().getServices().stream().filter(srv -> "SPARK_ON_YARN".equals(srv.getServiceType())).findAny().get();
ApiClusterTemplateRoleConfigGroup gw = service.getRoleConfigGroups().stream().filter(rcg -> "GATEWAY".equals(rcg.getRoleType())).findAny().get();
List<ApiClusterTemplateConfig> gwConfigs = gw.getConfigs();
assertEquals(1, gwConfigs.size());
assertEquals("spark-conf/spark-defaults.conf_client_config_safety_valve", gwConfigs.get(0).getName());
assertTrue(gwConfigs.get(0).getValue().startsWith("testkey=testvalue"));
assertTrue(gwConfigs.get(0).getValue().endsWith("spark.yarn.access.hadoopFileSystems=s3a://expn-cis-sandbox-prod-cdp-us-east-1"));
assertTrue(gwConfigs.get(0).getValue().contains("\n"));
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup in project cloudbreak by hortonworks.
the class CmTemplateProcessorTest method addExistingRoleConfigs.
@Test
public void addExistingRoleConfigs() {
underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-existing-conf.bp"));
Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
configs.put("hdfs-NAMENODE-BASE", List.of(new ApiClusterTemplateConfig().name("dfs_name_dir_list").variable("master_NAMENODE")));
configs.put("hdfs-DATANODE-BASE", List.of(new ApiClusterTemplateConfig().name("dfs_data_dir_list").variable("worker_DATANODE"), new ApiClusterTemplateConfig().name("dfs_data_dir_list_2").variable("worker_DATANODE_2")));
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();
assertEquals(1, nnConfigs.size());
assertEquals(4, dnConfigs.size());
assertEquals("dfs_name_dir_list", nnConfigs.get(0).getName());
ApiClusterTemplateConfig dfs1Config = dnConfigs.stream().filter(c -> "dfs_data_dir_list".equals(c.getName())).findFirst().get();
assertEquals("/dfs/dn", dfs1Config.getValue());
assertNull(dfs1Config.getVariable());
ApiClusterTemplateConfig dfs2Config = dnConfigs.stream().filter(c -> "dfs_data_dir_list_2".equals(c.getName())).findFirst().get();
assertEquals("worker_DATANODE_2", dfs2Config.getVariable());
assertNull(dfs2Config.getValue());
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup 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());
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup in project cloudbreak by hortonworks.
the class GeneratedCmTemplateService method prepareApiClusterTemplateServices.
private List<ApiClusterTemplateService> prepareApiClusterTemplateServices(Set<ServiceConfig> serviceConfigs, Map<String, Set<String>> hostServiceMap) {
List<ApiClusterTemplateService> clusterTemplateServices = new ArrayList<>();
for (ServiceConfig serviceConfig : serviceConfigs) {
String serviceName = serviceConfig.getName();
String lowerCaseServiceName = serviceName.toLowerCase();
ApiClusterTemplateService apiClusterTemplateService = new ApiClusterTemplateService();
apiClusterTemplateService.setRefName(lowerCaseServiceName);
apiClusterTemplateService.setServiceType(serviceName);
apiClusterTemplateService.setRoleConfigGroups(new ArrayList<>());
serviceConfig.getComponents().forEach(component -> {
Set<ApiClusterTemplateRoleConfigGroup> roleConfigGroups = new HashSet<>();
component.getGroups().forEach(group -> {
String componentName = component.getName();
boolean base = component.getGroups().size() == 1 || component.isBase();
String hostServiceNameEnd = base ? "BASE" : group.toUpperCase();
String hostServiceName = String.format("%s-%s-%s", lowerCaseServiceName, component.getName().toUpperCase(), hostServiceNameEnd);
ApiClusterTemplateRoleConfigGroup apiClusterTemplateRoleConfigGroup = new ApiClusterTemplateRoleConfigGroup();
apiClusterTemplateRoleConfigGroup.setRoleType(componentName.toUpperCase());
apiClusterTemplateRoleConfigGroup.setRefName(hostServiceName);
apiClusterTemplateRoleConfigGroup.setBase(base);
if (hostServiceMap.keySet().contains(group)) {
hostServiceMap.get(group).add(hostServiceName);
} else {
hostServiceMap.put(group, Sets.newHashSet(hostServiceName));
}
roleConfigGroups.add(apiClusterTemplateRoleConfigGroup);
});
apiClusterTemplateService.getRoleConfigGroups().addAll(roleConfigGroups);
});
clusterTemplateServices.add(apiClusterTemplateService);
}
return clusterTemplateServices;
}
use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup in project cloudbreak by hortonworks.
the class CmTemplateProcessor method getCustomRoleConfigsMap.
public Map<String, List<ApiClusterTemplateRoleConfigGroup>> getCustomRoleConfigsMap(Set<CustomConfigurationPropertyView> configProperties) {
Map<String, List<ApiClusterTemplateRoleConfigGroup>> roleConfigsMap = new HashMap<>();
List<CustomConfigurationPropertyView> roleConfigGroups = getCustomRoleConfigs(configProperties);
roleConfigGroups.forEach(roleConfigProperty -> {
String name = roleConfigProperty.getName();
String value = roleConfigProperty.getValue();
String service = roleConfigProperty.getServiceType();
String role = roleConfigProperty.getRoleType();
roleConfigsMap.computeIfAbsent(service, k -> new ArrayList<>());
Optional<ApiClusterTemplateRoleConfigGroup> roleConfigGroup = filterRCGsByRoleType(roleConfigsMap.get(service), role);
if (roleConfigGroup.isPresent()) {
roleConfigGroup.get().getConfigs().add(new ApiClusterTemplateConfig().name(name).value(value));
} else {
ApiClusterTemplateRoleConfigGroup roleToAdd = new ApiClusterTemplateRoleConfigGroup().roleType(role).addConfigsItem(new ApiClusterTemplateConfig().name(name).value(value));
roleConfigsMap.get(service).add(roleToAdd);
}
});
return roleConfigsMap;
}
Aggregations