Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 cee80132a -> 1182cc612


AMBARI-15783: Assign Slaves and Clients Page: Incorrect validation error shown 
(mithmatt)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1182cc61
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1182cc61
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1182cc61

Branch: refs/heads/branch-2.2
Commit: 1182cc6128eb6a559f6379379a14dd28786ba486
Parents: cee8013
Author: Matt <[email protected]>
Authored: Mon Apr 11 17:32:01 2016 -0700
Committer: Matt <[email protected]>
Committed: Mon Apr 11 17:32:01 2016 -0700

----------------------------------------------------------------------
 .../src/main/resources/stacks/stack_advisor.py  | 22 ++++++++++----------
 .../stacks/2.0.6/common/test_stack_advisor.py   |  5 +++--
 2 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1182cc61/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 636de01..539bd25 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -387,21 +387,20 @@ class DefaultStackAdvisor(StackAdvisor):
       for component in slaveClientComponents:
         componentName = component["StackServiceComponents"]["component_name"]
 
-        componentIsPopulated = self.isComponentHostsPopulated(component)
-        hostsForComponent = []
-
-        if componentIsPopulated:
-          hostsForComponent = component["StackServiceComponents"]["hostnames"]
+        if component["StackServiceComponents"]["cardinality"] == "ALL":
+          hostsForComponent = hostsList
         else:
+          componentIsPopulated = self.isComponentHostsPopulated(component)
+          if componentIsPopulated:
+            hostsForComponent = 
component["StackServiceComponents"]["hostnames"]
+          else:
+            hostsForComponent = []
 
           if self.isSlaveComponent(component):
             cardinality = 
str(component["StackServiceComponents"]["cardinality"])
             if self.isComponentUsingCardinalityForLayout(componentName) and 
cardinality:
               # cardinality types: 1+, 1-2, 1, ALL
-              if cardinality == "ALL":
-                hostsMin = len(hostsList)
-                hostsForComponent = hostsList
-              elif "+" in cardinality:
+              if "+" in cardinality:
                 hostsMin = int(cardinality[:-1])
               elif "-" in cardinality:
                 nums = cardinality.split("-")
@@ -410,12 +409,13 @@ class DefaultStackAdvisor(StackAdvisor):
                 hostsMin = int(cardinality)
               if hostsMin > len(hostsForComponent):
                 
hostsForComponent.extend(freeHosts[0:hostsMin-len(hostsForComponent)])
-            else:
+            # Components which are already installed, keep the recommendation 
as the existing layout
+            elif not componentIsPopulated:
               hostsForComponent.extend(freeHosts)
               if not hostsForComponent:  # hostsForComponent is empty
                 hostsForComponent = hostsList[-1:]
             hostsForComponent = list(set(hostsForComponent))  # removing 
duplicates
-          elif self.isClientComponent(component):
+          elif self.isClientComponent(component) and not componentIsPopulated:
             hostsForComponent = freeHosts[0:1]
             if not hostsForComponent:  # hostsForComponent is empty
               hostsForComponent = hostsList[-1:]

http://git-wip-us.apache.org/repos/asf/ambari/blob/1182cc61/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 c577538..18749e6 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
@@ -79,7 +79,8 @@ class TestHDP206StackAdvisor(TestCase):
     }
     self.assertHostLayout(expectedComponentsHostsMap, result)
 
-  def test_recommendationAssignmentNotChanged(self):
+  def test_recommendOnAllHosts(self):
+    """ Recommend on all hosts for cardinality ALL even if the component has 
been installed in the cluster before """
     servicesInfo = [
       {
         "name": "GANGLIA",
@@ -91,7 +92,7 @@ class TestHDP206StackAdvisor(TestCase):
     result = self.stackAdvisor.recommendComponentLayout(services, hosts)
 
     expectedComponentsHostsMap = {
-      "GANGLIA_MONITOR": ["host1"]
+      "GANGLIA_MONITOR": ["host1", "host2"]
     }
     self.assertHostLayout(expectedComponentsHostsMap, result)
 

Reply via email to