Repository: ambari Updated Branches: refs/heads/trunk edc8d14ec -> fe690bfdc
AMBARI-14104. Recommendations not applied if cluster creation template not contains all of the hostgroups. (Oliver Szabo via rnettleton) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fe690bfd Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fe690bfd Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fe690bfd Branch: refs/heads/trunk Commit: fe690bfdc71ecfb0d66285a13ab2b3babccb0b8d Parents: edc8d14 Author: Bob Nettleton <rnettle...@hortonworks.com> Authored: Mon Nov 30 16:51:05 2015 -0500 Committer: Bob Nettleton <rnettle...@hortonworks.com> Committed: Mon Nov 30 16:51:05 2015 -0500 ---------------------------------------------------------------------- .../stackadvisor/StackAdvisorBlueprintProcessor.java | 14 ++++++++------ .../StackAdvisorBlueprintProcessorTest.java | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fe690bfd/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java index 0325885..d57c17d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java @@ -129,13 +129,15 @@ public class StackAdvisorBlueprintProcessor { Set<String> components = hgComponents.getValue(); Set<String> hosts = bindingHostGroups.get(hgName); - for (String component : components) { - Set<String> componentHosts = componentHostsMap.get(component); - if (componentHosts == null) { // if was not initialized - componentHosts = new HashSet<String>(); - componentHostsMap.put(component, componentHosts); + if (hosts != null) { + for (String component : components) { + Set<String> componentHosts = componentHostsMap.get(component); + if (componentHosts == null) { // if was not initialized + componentHosts = new HashSet<String>(); + componentHostsMap.put(component, componentHosts); + } + componentHosts.addAll(hosts); } - componentHosts.addAll(hosts); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/fe690bfd/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java index 2baa505..514e6ab 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java @@ -161,6 +161,8 @@ public class StackAdvisorBlueprintProcessorTest { private Map<String, HostGroup> createHostGroupMap() { Map<String, HostGroup> hgMap = Maps.newHashMap(); hgMap.put("hg1", hostGroup); + hgMap.put("hg2", hostGroup); + hgMap.put("hg3", hostGroup); return hgMap; }