class ImpalaVolumeConfigProvider implements CmHostGroupRoleConfigProvider {

    @Override
    public List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, HostgroupView hostGroupView, TemplatePreparationObject source) {
        switch (roleType) {
            case ImpalaRoles.ROLE_IMPALAD:
                Integer minAttachedVolumeSize = hostGroupView.getVolumeTemplates().stream()
                        .mapToInt(volume -> volume.getVolumeSize())
                        .min()
                        .orElse(0);

                List<ApiClusterTemplateConfig> configs = new ArrayList<>();
                configs.add(config(IMPALA_SCRATCH_DIRS_PARAM,
                        buildVolumePathStringZeroVolumeHandled(hostGroupView.getVolumeCount(), "impala/scratch")));

                if (minAttachedVolumeSize > MIN_ATTACHED_VOLUME_SIZE_TO_ENABLE_CACHE_IN_GB
                        && hostGroupView.getVolumeCount() > 0) {
                    long dataCacheCapacityInBytes = VolumeUtils
                            .convertGBToBytes(Math.min(minAttachedVolumeSize / 2, MAX_IMPALA_DATA_CACHE_SIZE_IN_GB / hostGroupView.getVolumeCount()));

                    configs.add(config(IMPALA_DATACACHE_ENABLED_PARAM, "true"));
                    configs.add(config(IMPALA_DATACACHE_CAPACITY_PARAM, Long.toString(dataCacheCapacityInBytes)));
                    configs.add(config(IMPALA_DATACACHE_DIRS_PARAM,
                            buildVolumePathStringZeroVolumeHandled(hostGroupView.getVolumeCount(), "impala/datacache")));
                }
                return configs;

            default:
                return List.of();
        }
    }

}