Search in sources :

Example 1 with CustomConfigurationPropertyView

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));
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 2 with CustomConfigurationPropertyView

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));
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) 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 3 with CustomConfigurationPropertyView

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;
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) List(java.util.List) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Example 4 with CustomConfigurationPropertyView

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);
}
Also used : CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.Test)

Example 5 with CustomConfigurationPropertyView

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;
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) List(java.util.List) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Aggregations

CustomConfigurationPropertyView (com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView)5 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)2 Test (org.junit.jupiter.api.Test)2 ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)1 Test (org.junit.Test)1