@Override
public Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster) throws AmbariException {
Map<String, HostConfig> hostConfigMap = new HashMap<String, HostConfig>();
for (Map.Entry<String, DesiredConfig> desiredConfigEntry :
cluster.getDesiredConfigs().entrySet()) {
HostConfig hostConfig = new HostConfig();
hostConfig.setDefaultVersionTag(desiredConfigEntry.getValue().getVersion());
hostConfigMap.put(desiredConfigEntry.getKey(), hostConfig);
}
Map<Long, ConfigGroup> configGroups = cluster.getConfigGroupsByHostname(this.getHostName());
if (configGroups != null && !configGroups.isEmpty()) {
for (ConfigGroup configGroup : configGroups.values()) {
for (Map.Entry<String, Config> configEntry : configGroup
.getConfigurations().entrySet()) {
String configType = configEntry.getKey();
// HostConfig config holds configType -> versionTag, per config group
HostConfig hostConfig = hostConfigMap.get(configType);
if (hostConfig == null) {
hostConfig = new HostConfig();
hostConfigMap.put(configType, hostConfig);
hostConfig.setDefaultVersionTag(cluster.getDesiredConfigByType
(configType).getVersionTag());
}
Config config = configEntry.getValue();
hostConfig.getConfigGroupOverrides().put(configGroup.getId(),
config.getVersionTag());
}
}
}
return hostConfigMap;