@Test void getRoleConfigsWithMultipleVolumes() { HostgroupView hostGroup = hostGroupWithVolumeCount(2); assertEquals(List.of(config("dfs_data_dir_list", "/hadoopfs/fs1/datanode,/hadoopfs/fs2/datanode")), subject.getRoleConfigs(HdfsRoles.DATANODE, hostGroup, preparatorWithHostGroups(hostGroup)) ); assertEquals(List.of(config("dfs_name_dir_list", "/hadoopfs/fs1/namenode,/hadoopfs/fs2/namenode")), subject.getRoleConfigs(HdfsRoles.NAMENODE, hostGroup, preparatorWithHostGroups(hostGroup)) ); assertEquals(List.of(config("fs_checkpoint_dir_list", "/hadoopfs/fs1/namesecondary,/hadoopfs/fs2/namesecondary")), subject.getRoleConfigs(HdfsRoles.SECONDARYNAMENODE, hostGroup, preparatorWithHostGroups(hostGroup)) ); assertEquals(List.of(config("dfs_journalnode_edits_dir", "/hadoopfs/fs1/journalnode")), subject.getRoleConfigs(HdfsRoles.JOURNALNODE, hostGroup, preparatorWithHostGroups(hostGroup)) ); }
@Override public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) { Integer volumeCount = Objects.nonNull(hostGroupView) ? hostGroupView.getVolumeCount() : 0; switch (roleType) { case HdfsRoles.DATANODE: return List.of( config("dfs_data_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "datanode")) ); case HdfsRoles.NAMENODE: return List.of( config("dfs_name_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namenode")) ); case HdfsRoles.SECONDARYNAMENODE: return List.of( config("fs_checkpoint_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namesecondary")) ); case HdfsRoles.JOURNALNODE: return List.of( config("dfs_journalnode_edits_dir", buildSingleVolumePath(volumeCount, "journalnode")) ); default: return List.of(); } }
HdfsVolumeConfigProvider implements CmHostGroupRoleConfigProvider { @Override public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) { Integer volumeCount = Objects.nonNull(hostGroupView) ? hostGroupView.getVolumeCount() : 0; switch (roleType) { case HdfsRoles.DATANODE: return List.of( config("dfs_data_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "datanode")) ); case HdfsRoles.NAMENODE: return List.of( config("dfs_name_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namenode")) ); case HdfsRoles.SECONDARYNAMENODE: return List.of( config("fs_checkpoint_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namesecondary")) ); case HdfsRoles.JOURNALNODE: return List.of( config("dfs_journalnode_edits_dir", buildSingleVolumePath(volumeCount, "journalnode")) ); default: return List.of(); } } }
HdfsVolumeConfigProvider implements CmHostGroupRoleConfigProvider { @Override public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) { Integer volumeCount = Objects.nonNull(hostGroupView) ? hostGroupView.getVolumeCount() : 0; switch (roleType) { case HdfsRoles.DATANODE: return List.of( config("dfs_data_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "datanode")) ); case HdfsRoles.NAMENODE: return List.of( config("dfs_name_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namenode")) ); case HdfsRoles.SECONDARYNAMENODE: return List.of( config("fs_checkpoint_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namesecondary")) ); case HdfsRoles.JOURNALNODE: return List.of( config("dfs_journalnode_edits_dir", buildSingleVolumePath(volumeCount, "journalnode")) ); default: return List.of(); } }  }
HdfsVolumeConfigProvider implements CmHostGroupRoleConfigProvider { @Override public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) { Integer volumeCount = Objects.nonNull(hostGroupView) ? hostGroupView.getVolumeCount() : 0; switch (roleType) { case HdfsRoles.DATANODE: return List.of( config("dfs_data_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "datanode")) ); case HdfsRoles.NAMENODE: return List.of( config("dfs_name_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namenode")) ); case HdfsRoles.SECONDARYNAMENODE: return List.of( config("fs_checkpoint_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namesecondary")) ); case HdfsRoles.JOURNALNODE: return List.of( config("dfs_journalnode_edits_dir", buildSingleVolumePath(volumeCount, "journalnode")) ); default: return List.of(); } }  @Override List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source); @Override String getServiceType(); @Override Set<String> getRoleTypes(); @Override boolean sharedRoleType(String roleType); }
HdfsVolumeConfigProvider implements CmHostGroupRoleConfigProvider { @Override public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) { Integer volumeCount = Objects.nonNull(hostGroupView) ? hostGroupView.getVolumeCount() : 0; switch (roleType) { case HdfsRoles.DATANODE: return List.of( config("dfs_data_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "datanode")) ); case HdfsRoles.NAMENODE: return List.of( config("dfs_name_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namenode")) ); case HdfsRoles.SECONDARYNAMENODE: return List.of( config("fs_checkpoint_dir_list", buildVolumePathStringZeroVolumeHandled(volumeCount, "namesecondary")) ); case HdfsRoles.JOURNALNODE: return List.of( config("dfs_journalnode_edits_dir", buildSingleVolumePath(volumeCount, "journalnode")) ); default: return List.of(); } }  @Override List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source); @Override String getServiceType(); @Override Set<String> getRoleTypes(); @Override boolean sharedRoleType(String roleType);  }