ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [16/30] ambari git commit: AMBARI-19764. yarn.min.container.size is read incorrectly on first load of the Hive config page (smohanty)
Date Mon, 30 Jan 2017 15:40:37 GMT
AMBARI-19764. yarn.min.container.size is read incorrectly on first load of the Hive config
page (smohanty)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 1eb4ca50b5043ebd8326db90851520f3ea359731
Parents: 716b2fc
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Sun Jan 29 08:45:39 2017 -0800
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Sun Jan 29 08:45:39 2017 -0800

----------------------------------------------------------------------
 .../stacks/HDP/2.0.6/services/stack_advisor.py  |  12 ++
 .../src/main/resources/stacks/stack_advisor.py  |  38 ++++-
 .../stacks/2.0.6/common/test_stack_advisor.py   | 148 +++++++++++++++++++
 3 files changed, 191 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1eb4ca50/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index af4539d..5c68f15 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -1457,6 +1457,18 @@ def getUserOperationContext(services, contextName):
         return userContext[contextName]
   return None
 
+# if serviceName is being added
+def isServiceBeingAdded(services, serviceName):
+  if services:
+    if 'user-context' in services.keys():
+      userContext = services["user-context"]
+      if DefaultStackAdvisor.OPERATION in userContext and \
+              'AddService' == userContext[DefaultStackAdvisor.OPERATION] and \
+              DefaultStackAdvisor.OPERATION_DETAILS in userContext:
+        if -1 != userContext["operation_details"].find(serviceName):
+          return True
+  return False
+
 # Validation helper methods
 def getSiteProperties(configurations, siteName):
   siteConfig = configurations.get(siteName)

http://git-wip-us.apache.org/repos/asf/ambari/blob/1eb4ca50/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 9eb3973..d4b9ab7 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -1024,15 +1024,25 @@ class DefaultStackAdvisor(StackAdvisor):
     callContext = self.getCallContext(services)
 
     operation = self.getUserOperationContext(services, DefaultStackAdvisor.OPERATION)
+    adding_yarn = self.isServiceBeingAdded(services, 'YARN')
     if operation:
       Logger.info("user operation context : " + str(operation))
 
     if services:  # its never None but some unit tests pass it as None
       # If min container value is changed (user is changing it)
-      # if its a validation call - just used what ever value is set
-      # If its not a cluster create or add yarn service (TBD)
-      if (self.getOldValue(services, "yarn-site", "yarn.scheduler.minimum-allocation-mb")
or \
-                'recommendConfigurations' != callContext) and operation != DefaultStackAdvisor.CLUSTER_CREATE_OPERATION:
+      # if its a validation call - just use what ever value is set
+      # If its a recommend attribute call (when UI lands on a page)
+      # If add service but YARN is not being added
+      if self.getOldValue(services, "yarn-site", "yarn.scheduler.minimum-allocation-mb")
or \
+              'recommendConfigurations' != callContext or \
+              operation == DefaultStackAdvisor.RECOMMEND_ATTRIBUTE_OPERATION or \
+          (operation == DefaultStackAdvisor.ADD_SERVICE_OPERATION and not adding_yarn):
+
+        Logger.info("Full context: callContext = " + str(callContext) +
+                    " and operation = " + str(operation) + " and adding YARN = " + str(adding_yarn)
+
+                    " and old value exists = " +
+                    str(self.getOldValue(services, "yarn-site", "yarn.scheduler.minimum-allocation-mb")))
+
         '''yarn.scheduler.minimum-allocation-mb has changed - then pick this value up'''
         if "yarn-site" in services["configurations"] and \
                 "yarn.scheduler.minimum-allocation-mb" in services["configurations"]["yarn-site"]["properties"]
and \
@@ -1087,11 +1097,25 @@ class DefaultStackAdvisor(StackAdvisor):
 
   def getCallContext(self, services):
     if services:
-      if 'context' in services:
-        Logger.info("context : " + str (services['context']))
-        return services['context']['call_type']
+      if DefaultStackAdvisor.ADVISOR_CONTEXT in services:
+        Logger.info("call type context : " + str(services[DefaultStackAdvisor.ADVISOR_CONTEXT]))
+        return services[DefaultStackAdvisor.ADVISOR_CONTEXT][DefaultStackAdvisor.CALL_TYPE]
     return ""
 
+
+  # if serviceName is being added
+  def isServiceBeingAdded(self, services, serviceName):
+    if services:
+      if 'user-context' in services.keys():
+        userContext = services["user-context"]
+        if DefaultStackAdvisor.OPERATION in userContext and \
+              'AddService' == userContext[DefaultStackAdvisor.OPERATION] and \
+              DefaultStackAdvisor.OPERATION_DETAILS in userContext:
+          if -1 != userContext["operation_details"].find(serviceName):
+            return True
+    return False
+
+
   def getUserOperationContext(self, services, contextName):
     if services:
       if 'user-context' in services.keys():

http://git-wip-us.apache.org/repos/asf/ambari/blob/1eb4ca50/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 388d7f8..60c48d6 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
@@ -700,6 +700,154 @@ class TestHDP206StackAdvisor(TestCase):
     result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components,
services)
     self.assertEquals(result, expected_2048)
 
+    # Recommend attribute call - pick user specified value
+    services = {"services":
+                  [{"StackServices":
+                      {"service_name": "YARN",
+                       "service_version": "2.6.0.2.2"
+                      },
+                    "components": [
+                      {
+                        "StackServiceComponents": {
+                          "advertise_version": "true",
+                          "cardinality": "1+",
+                          "component_category": "SLAVE",
+                          "component_name": "NODEMANAGER",
+                          "custom_commands": [
+
+                          ],
+                          "display_name": "NodeManager",
+                          "is_client": "false",
+                          "is_master": "false",
+                          "service_name": "YARN",
+                          "stack_name": "HDP",
+                          "stack_version": "2.2",
+                          "hostnames": [
+                            "host1"
+                          ]
+                        },
+                        "dependencies": [
+                        ]
+                      }
+                    ],
+                    }],
+                "configurations": {
+                  "yarn-site": {
+                    "properties": {
+                      "yarn.scheduler.minimum-allocation-mb": "2048",
+                      "yarn.scheduler.maximum-allocation-mb": "12288"
+                    }
+                  }
+                },
+                "changed-configurations": [],
+                "user-context" : {
+                  "operation" : "RecommendAttribute"
+                },
+                "advisor_context": {'call_type': 'recommendConfigurations'}
+    }
+
+    result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components,
services)
+    self.assertEquals(result, expected_2048)
+
+    # Add service and not adding YARN - pick user specified value
+    services = {"services":
+                  [{"StackServices":
+                      {"service_name": "YARN",
+                       "service_version": "2.6.0.2.2"
+                      },
+                    "components": [
+                      {
+                        "StackServiceComponents": {
+                          "advertise_version": "true",
+                          "cardinality": "1+",
+                          "component_category": "SLAVE",
+                          "component_name": "NODEMANAGER",
+                          "custom_commands": [
+
+                          ],
+                          "display_name": "NodeManager",
+                          "is_client": "false",
+                          "is_master": "false",
+                          "service_name": "YARN",
+                          "stack_name": "HDP",
+                          "stack_version": "2.2",
+                          "hostnames": [
+                            "host1"
+                          ]
+                        },
+                        "dependencies": [
+                        ]
+                      }
+                    ],
+                    }],
+                "configurations": {
+                  "yarn-site": {
+                    "properties": {
+                      "yarn.scheduler.minimum-allocation-mb": "2048",
+                      "yarn.scheduler.maximum-allocation-mb": "12288"
+                    }
+                  }
+                },
+                "changed-configurations": [],
+                "user-context" : {
+                  "operation" : "AddService",
+                  "operation_details" : "TEZ,HIVE,SLIDER"
+                },
+                "advisor_context": {'call_type': 'recommendConfigurations'}
+    }
+
+    result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components,
services)
+    self.assertEquals(result, expected_2048)
+
+    # Add service and adding YARN - compute the value
+    services = {"services":
+                  [{"StackServices":
+                      {"service_name": "YARN",
+                       "service_version": "2.6.0.2.2"
+                      },
+                    "components": [
+                      {
+                        "StackServiceComponents": {
+                          "advertise_version": "true",
+                          "cardinality": "1+",
+                          "component_category": "SLAVE",
+                          "component_name": "NODEMANAGER",
+                          "custom_commands": [
+
+                          ],
+                          "display_name": "NodeManager",
+                          "is_client": "false",
+                          "is_master": "false",
+                          "service_name": "YARN",
+                          "stack_name": "HDP",
+                          "stack_version": "2.2",
+                          "hostnames": [
+                            "host1"
+                          ]
+                        },
+                        "dependencies": [
+                        ]
+                      }
+                    ],
+                    }],
+                "configurations": {
+                  "yarn-site": {
+                    "properties": {
+                      "yarn.scheduler.minimum-allocation-mb": "512"
+                    }
+                  }
+                },
+                "changed-configurations": [],
+                "user-context" : {
+                  "operation" : "AddService",
+                  "operation_details" : "TEZ,HIVE,YARN,SLIDER"
+                },
+                "advisor_context": {'call_type': 'recommendConfigurations'}
+    }
+
+    result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components,
services)
+    self.assertEquals(result, expected)
+
     # Recommend config dependencies call - pick user specified value
     services = {"services":
                   [{"StackServices":


Mime
View raw message