@Test public void testGenerateConfigsWhenHdfsJournalNodeNull() { HostgroupView master1 = new HostgroupView("master1", 1, InstanceGroupType.GATEWAY, 1); HostgroupView master2 = new HostgroupView("master2", 1, InstanceGroupType.GATEWAY, 1); HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2); HostgroupView compute = new HostgroupView("compute", 3, InstanceGroupType.CORE, 2); HostgroupView quorum = new HostgroupView("quorum", 3, InstanceGroupType.CORE, 2); setup("input/cb5660.bp", Builder.builder().withHostgroupViews(Set.of(master1, master2, worker, compute, quorum))); Map<String, Map<String, List<ApiClusterTemplateConfig>>> actual = underTest.generateConfigs(templateProcessor, templatePreparator); assertNotNull(actual.get("hdfs-JOURNALNODE-BASE")); assertNotNull(actual.get("zookeeper-SERVER-BASE")); }
@VisibleForTesting Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) { Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>(); Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity())); List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor); Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents(); for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) { String hostGroupName = hostTemplate.getRefName(); List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of); HostgroupView hostgroupView = hostGroups.get(hostGroupName); groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView); } return configsByRoleConfigGroup; }
CmHostGroupRoleConfigProviderProcessor { @VisibleForTesting Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) { Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>(); Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity())); List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor); Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents(); for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) { String hostGroupName = hostTemplate.getRefName(); List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of); HostgroupView hostgroupView = hostGroups.get(hostGroupName); groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView); } return configsByRoleConfigGroup; } }
CmHostGroupRoleConfigProviderProcessor { @VisibleForTesting Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) { Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>(); Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity())); List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor); Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents(); for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) { String hostGroupName = hostTemplate.getRefName(); List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of); HostgroupView hostgroupView = hostGroups.get(hostGroupName); groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView); } return configsByRoleConfigGroup; }  }
CmHostGroupRoleConfigProviderProcessor { @VisibleForTesting Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) { Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>(); Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity())); List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor); Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents(); for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) { String hostGroupName = hostTemplate.getRefName(); List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of); HostgroupView hostgroupView = hostGroups.get(hostGroupName); groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView); } return configsByRoleConfigGroup; }  void process(CmTemplateProcessor templateProcessor, TemplatePreparationObject source); }
CmHostGroupRoleConfigProviderProcessor { @VisibleForTesting Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) { Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>(); Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity())); List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor); Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents(); for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) { String hostGroupName = hostTemplate.getRefName(); List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of); HostgroupView hostgroupView = hostGroups.get(hostGroupName); groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView); } return configsByRoleConfigGroup; }  void process(CmTemplateProcessor templateProcessor, TemplatePreparationObject source);  }