Repository: ambari Updated Branches: refs/heads/trunk e803670a8 -> 694ca91fd
AMBARI-9108. Error on Assign Slaves + Clients page when adding new hosts. (Antonenko Alexander via mahadev) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/694ca91f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/694ca91f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/694ca91f Branch: refs/heads/trunk Commit: 694ca91fd57665c8f2a60d1fc675165bea5481fe Parents: e803670 Author: Mahadev Konar <maha...@apache.org> Authored: Mon Jan 26 11:59:07 2015 -0800 Committer: Mahadev Konar <maha...@apache.org> Committed: Mon Jan 26 11:59:07 2015 -0800 ---------------------------------------------------------------------- .../src/main/resources/stacks/stack_advisor.py | 22 +++++++++++++------- .../stacks/2.0.6/common/test_stack_advisor.py | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/694ca91f/ambari-server/src/main/resources/stacks/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py index 81d2288..3d22d92 100644 --- a/ambari-server/src/main/resources/stacks/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/stack_advisor.py @@ -386,17 +386,23 @@ class DefaultStackAdvisor(StackAdvisor): for component in slaveClientComponents: componentName = component["StackServiceComponents"]["component_name"] - if self.isComponentHostsPopulated(component): - hostsForComponent = component["StackServiceComponents"]["hostnames"] - elif component["StackServiceComponents"]["cardinality"] == "ALL": + if component["StackServiceComponents"]["cardinality"] == "ALL": hostsForComponent = hostsList else: - if len(freeHosts) == 0: + componentIsPopulated = self.isComponentHostsPopulated(component) + if componentIsPopulated: + hostsForComponent = component["StackServiceComponents"]["hostnames"] + else: + hostsForComponent = [] + + if self.isSlaveComponent(component): + hostsForComponent.extend(freeHosts) + hostsForComponent = list(set(hostsForComponent)) # removing duplicates + elif self.isClientComponent(component) and not componentIsPopulated: + hostsForComponent = freeHosts[0:1] + + if not hostsForComponent: # hostsForComponent is empty hostsForComponent = hostsList[-1:] - else: # len(freeHosts) >= 1 - hostsForComponent = freeHosts - if self.isClientComponent(component): - hostsForComponent = freeHosts[0:1] #extend 'hostsComponentsMap' with 'hostsForComponent' for hostName in hostsForComponent: http://git-wip-us.apache.org/repos/asf/ambari/blob/694ca91f/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py index 3a8d79b..bae5ef8 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py @@ -91,7 +91,7 @@ class TestHDP206StackAdvisor(TestCase): result = self.stackAdvisor.recommendComponentLayout(services, hosts) expectedComponentsHostsMap = { - "GANGLIA_MONITOR": ["host1"] + "GANGLIA_MONITOR": ["host1", "host2"] } self.assertHostLayout(expectedComponentsHostsMap, result)