Updated Branches: refs/heads/trunk c66287359 -> eb5c0b619
AMBARI-3895. Stale_configs flag not updated when host moves back to default config-group. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eb5c0b61 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eb5c0b61 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eb5c0b61 Branch: refs/heads/trunk Commit: eb5c0b619146f461dbfd5b644f3635eec914224a Parents: c662873 Author: Siddharth Wagle <[email protected]> Authored: Tue Nov 26 17:28:56 2013 -0800 Committer: Siddharth Wagle <[email protected]> Committed: Tue Nov 26 17:30:51 2013 -0800 ---------------------------------------------------------------------- .../apache/ambari/server/state/ConfigHelper.java | 17 ++++++----------- .../java/org/apache/ambari/server/state/Host.java | 6 ++++++ .../apache/ambari/server/state/host/HostImpl.java | 6 ++++++ 3 files changed, 18 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/eb5c0b61/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java index 5fb7667..964d2d6 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java @@ -257,7 +257,6 @@ public class ConfigHelper { // --- desired tags DO match actual tags: not_stale // --- desired tags DO NOT match actual tags // ---- merge values, determine changed keys, check stack: stale - boolean stale = false; Iterator<Entry<String, Map<String, String>>> it = desired.entrySet().iterator(); @@ -294,7 +293,8 @@ public class ConfigHelper { // tags are changed, need to find out what has changed, // and if it applies // to the service - Collection<String> changed = findChangedKeys(cluster, type, tags.values(), actualTags.values()); + Collection<String> changed = findChangedKeys(cluster, type, + tags.values(), actualTags.values()); if (serviceInfo.hasPropertyFor(type, changed)) { stale = true; } @@ -312,7 +312,6 @@ public class ConfigHelper { * @return <code>true</code> if any service on the stack defines a property * for the type. */ - private boolean hasPropertyFor(StackId stack, String type, Collection<String> keys) throws AmbariException { @@ -384,15 +383,11 @@ public class ConfigHelper { if (!actualTags.get(CLUSTER_DEFAULT_TAG).equals(desiredTags.get(CLUSTER_DEFAULT_TAG))) return true; - Set<String> desiredSet = new HashSet<String>(desiredTags.keySet()); - Set<String> actualSet = new HashSet<String>(actualTags.keySet()); - - desiredSet.removeAll(actualSet); + Set<String> desiredSet = new HashSet<String>(desiredTags.values()); + Set<String> actualSet = new HashSet<String>(actualTags.values()); - if (!desiredSet.isEmpty()) - return true; - - return false; + // Both desired and actual should be exactly the same + return !desiredSet.equals(actualSet); } /** http://git-wip-us.apache.org/repos/asf/ambari/blob/eb5c0b61/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java index 5eef430..3fc6efa 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java @@ -311,5 +311,11 @@ public interface Host { */ public Map<String, DesiredConfig> getDesiredConfigs(long clusterId); + /** + * Get the desired configurations for the host including overrides + * @param cluster + * @return + * @throws AmbariException + */ public Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster) throws AmbariException; } http://git-wip-us.apache.org/repos/asf/ambari/blob/eb5c0b61/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java index 567623e..d2e53ae 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java @@ -1175,6 +1175,12 @@ public class HostImpl implements Host { @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());
