Przeglądaj źródła

AMBARI-14301: Co-locate HAWQSEGMENT on hosts that have DATANODE component (lavjain via jaoki)

Jun Aoki 9 lat temu
rodzic
commit
fe8a8d1e16

+ 13 - 7
ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py

@@ -26,18 +26,24 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
     parentComponentLayoutRecommendations = super(HDP23StackAdvisor, self).createComponentLayoutRecommendations(services, hosts)
 
     hostsList = [host["Hosts"]["host_name"] for host in hosts["items"]]
+    hostGroups = parentComponentLayoutRecommendations["blueprint"]["host_groups"]
     servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
 
-    # remove HAWQSTANDBY on a single node
-    if len(hostsList) == 1 and "HAWQ" in servicesList:
-      components = parentComponentLayoutRecommendations["blueprint"]["host_groups"][0]["components"]
-      components = [ component for component in components if component["name"] != 'HAWQSTANDBY' ]
-      parentComponentLayoutRecommendations["blueprint"]["host_groups"][0]["components"] = components
+    if "HAWQ" in servicesList:
+      # remove HAWQSTANDBY on a single node
+      if len(hostsList) == 1:
+        components = parentComponentLayoutRecommendations["blueprint"]["host_groups"][0]["components"]
+        components = [component for component in components if component["name"] != 'HAWQSTANDBY']
+        parentComponentLayoutRecommendations["blueprint"]["host_groups"][0]["components"] = components
+
+      # co-locate HAWQSEGMENT with DATANODE
+      for host_group in hostGroups:
+        if {"name": "DATANODE"} in host_group["components"] and {"name": "HAWQSEGMENT"} not in host_group["components"]:
+          host_group["components"].append({"name": "HAWQSEGMENT"})
 
     # co-locate PXF with NAMENODE and DATANODE
     if "PXF" in servicesList:
-      host_groups = parentComponentLayoutRecommendations["blueprint"]["host_groups"]
-      for host_group in host_groups:
+      for host_group in hostGroups:
         if ({"name": "NAMENODE"} in host_group["components"] or {"name": "DATANODE"} in host_group["components"]) \
             and {"name": "PXF"} not in host_group["components"]:
           host_group["components"].append({"name": "PXF"})

+ 0 - 0
ambari-server/src/test/python/stacks/2.3/common/services-pxf-hdfs.json → ambari-server/src/test/python/stacks/2.3/common/services-hawq-pxf-hdfs.json


+ 14 - 1
ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py

@@ -155,7 +155,7 @@ class TestHDP23StackAdvisor(TestCase):
   def test_createComponentLayoutRecommendations_pxf_co_locate_with_namenode_or_datanode(self):
     """ Test that PXF gets recommended on same host group which has NAMENODE or DATANODE"""
 
-    services = self.load_json("services-pxf-hdfs.json")
+    services = self.load_json("services-hawq-pxf-hdfs.json")
     hosts = self.load_json("hosts-3-hosts.json")
     recommendations = self.stackAdvisor.createComponentLayoutRecommendations(services, hosts)
 
@@ -165,6 +165,19 @@ class TestHDP23StackAdvisor(TestCase):
         self.assertTrue("PXF" in component_names)
 
 
+  def test_hawqsegmentDatanode(self):
+    """ Test that HAWQSegment gets recommended on same host group which has DATANODE"""
+
+    services = self.load_json("services-hawq-pxf-hdfs.json")
+    hosts = self.load_json("hosts-3-hosts.json")
+    recommendations = self.stackAdvisor.createComponentLayoutRecommendations(services, hosts)
+
+    for hostgroup in recommendations["blueprint"]["host_groups"]:
+      component_names = [component["name"] for component in hostgroup["components"]]
+      if 'DATANODE' in component_names:
+        self.assertTrue('HAWQSEGMENT' in component_names)
+
+
   def fqdn_mock_result(value=None):
       return 'c6401.ambari.apache.org' if value is None else value