use of com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView in project cloudbreak by hortonworks.
the class CmTemplateProcessorTest method testIfCustomServiceConfigsMapIsRetrievedCorrectly.
@Test
void testIfCustomServiceConfigsMapIsRetrievedCorrectly() {
underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
Map<String, List<ApiClusterTemplateConfig>> expectedMap = new HashMap<>();
Set<CustomConfigurationPropertyView> configs = Set.of(new CustomConfigurationPropertyView("property1", "value1", null, "service1"), new CustomConfigurationPropertyView("property2", "value2", "role1", "service2"), new CustomConfigurationPropertyView("property3", "value3", null, "service3"));
expectedMap.put("service1", List.of(new ApiClusterTemplateConfig().name("property1").value("value1")));
expectedMap.put("service3", List.of(new ApiClusterTemplateConfig().name("property3").value("value3")));
assertEquals(expectedMap, underTest.getCustomServiceConfigsMap(configs));
}
use of com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView in project cloudbreak by hortonworks.
the class CmTemplateProcessorTest method testIfCustomRoleConfigsMapIsRetrievedCorrectly.
@Test
void testIfCustomRoleConfigsMapIsRetrievedCorrectly() {
underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
Map<String, List<ApiClusterTemplateRoleConfigGroup>> expectedMap = new HashMap<>();
Set<CustomConfigurationPropertyView> configs = Set.of(new CustomConfigurationPropertyView("property3", "value3", "role3", "service2"), new CustomConfigurationPropertyView("property2", "value2", "role2", "service1"), new CustomConfigurationPropertyView("property4", "value4", null, "service1"));
expectedMap.put("service2", List.of(new ApiClusterTemplateRoleConfigGroup().roleType("role3").addConfigsItem(new ApiClusterTemplateConfig().name("property3").value("value3"))));
expectedMap.put("service1", List.of(new ApiClusterTemplateRoleConfigGroup().roleType("role2").addConfigsItem(new ApiClusterTemplateConfig().name("property2").value("value2"))));
assertEquals(expectedMap, underTest.getCustomRoleConfigsMap(configs));
}
use of com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView in project cloudbreak by hortonworks.
the class CmTemplateProcessor method getCustomServiceConfigsMap.
public Map<String, List<ApiClusterTemplateConfig>> getCustomServiceConfigsMap(Set<CustomConfigurationPropertyView> configProperties) {
Map<String, List<ApiClusterTemplateConfig>> serviceConfigsMap = new HashMap<>();
List<CustomConfigurationPropertyView> serviceConfigs = getCustomServiceConfigs(configProperties);
serviceConfigs.forEach(serviceConfig -> {
serviceConfigsMap.computeIfAbsent(serviceConfig.getServiceType(), k -> new ArrayList<>());
serviceConfigsMap.get(serviceConfig.getServiceType()).add(new ApiClusterTemplateConfig().name(serviceConfig.getName()).value(serviceConfig.getValue()));
});
return serviceConfigsMap;
}
use of com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView in project cloudbreak by hortonworks.
the class CentralCmTemplateUpdaterTest method customConfigsAreInjected.
@Test
public void customConfigsAreInjected() {
when(customConfigurationsView.getConfigurations()).thenReturn(Set.of(new CustomConfigurationPropertyView("service_config_name", "service_config_value", null, "zookeeper"), new CustomConfigurationPropertyView("service_config_name", "service_config_value", null, "hdfs"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "server", "zookeeper"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "namenode", "hdfs"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "datanode", "hdfs"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "journalnode", "hdfs"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "failovercontroller", "hdfs"), new CustomConfigurationPropertyView("role_config_name", "role_config_value", "balancer", "hdfs")));
when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/namenode-ha.bp"));
ApiClusterTemplate generated = testGetCmTemplate();
assertMatchesBlueprintAtPath("output/namenode-ha-injected.bp", generated);
}
use of com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView 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