Repository: ambari
Updated Branches:
  refs/heads/trunk 8211d7a44 -> c17500a41


AMBARI-9778. In cluster layout recommendation, slave component cardinality of 
0+ not being used (aonishuk)


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

Branch: refs/heads/trunk
Commit: c17500a41bb24375a9b318f9be30a3465bf4014d
Parents: 8211d7a
Author: Andrew Onishuk <[email protected]>
Authored: Wed Feb 25 14:12:52 2015 +0200
Committer: Andrew Onishuk <[email protected]>
Committed: Wed Feb 25 14:12:52 2015 +0200

----------------------------------------------------------------------
 .../src/main/resources/stacks/stack_advisor.py  | 25 ++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c17500a4/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 3d22d92..42db088 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -396,13 +396,27 @@ class DefaultStackAdvisor(StackAdvisor):
             hostsForComponent = []
 
           if self.isSlaveComponent(component):
-            hostsForComponent.extend(freeHosts)
+            cardinality = 
str(component["StackServiceComponents"]["cardinality"])
+            if self.isComponentUsingCardinalityForLayout(componentName) and 
cardinality:
+              # cardinality types: 1+, 1-2, 1, ALL
+              if "+" in cardinality:
+                hostsMin = int(cardinality[:-1])
+              elif "-" in cardinality:
+                nums = cardinality.split("-")
+                hostsMin = int(nums[0])
+              else:
+                hostsMin = int(cardinality)
+              if hostsMin > len(hostsForComponent):
+                
hostsForComponent.extend(freeHosts[0:hostsMin-len(hostsForComponent)])
+            else:
+              hostsForComponent.extend(freeHosts)
+              if not hostsForComponent:  # hostsForComponent is empty
+                hostsForComponent = hostsList[-1:]
             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:]
+            if not hostsForComponent:  # hostsForComponent is empty
+              hostsForComponent = hostsList[-1:]
 
         #extend 'hostsComponentsMap' with 'hostsForComponent'
         for hostName in hostsForComponent:
@@ -423,6 +437,9 @@ class DefaultStackAdvisor(StackAdvisor):
     return recommendations
   pass
 
+  def isComponentUsingCardinalityForLayout(self, componentName):
+    return False
+
   def createValidationResponse(self, services, validationItems):
     """Returns array of Validation objects about issues with hostnames 
components assigned to"""
     stackName = services["Versions"]["stack_name"]

Reply via email to