You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2016/04/16 01:59:34 UTC

[1/2] ambari git commit: AMBARI-15876. HiveServerInteractive. Stack advisor work for adding and disabling LLAP queue when Interactive query is turned on and off respectively.

Repository: ambari
Updated Branches:
  refs/heads/trunk 08a933252 -> a224f2657


http://git-wip-us.apache.org/repos/asf/ambari/blob/a224f265/ambari-server/src/test/python/stacks/2.5/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.5/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.5/common/test_stack_advisor.py
index c21bad7..ccf368f 100644
--- a/ambari-server/src/test/python/stacks/2.5/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.5/common/test_stack_advisor.py
@@ -165,4 +165,1599 @@ class TestHDP25StackAdvisor(TestCase):
       {'config-type': 'hdfs-site', 'message': 'HIVE_SERVER_INTERACTIVE requires hive_server_interactive_host in hive-interactive-env set to its host name.', 'type': 'configuration', 'config-name': 'hive_server_interactive_host', 'level': 'WARN'}
     ]
     res = self.stackAdvisor.validateHiveInteractiveEnvConfigurations(properties, recommendedDefaults, configurations3, services, {})
-    self.assertEquals(res, res_expected)
\ No newline at end of file
+    self.assertEquals(res, res_expected)
+
+  def test_recommendYARNConfigurations(self):
+    ################ Setting up Inputs. #########################
+    hosts = {
+      "items": [
+        {
+          "Hosts": {
+            "cpu_count": 6,
+            "total_mem": 50331648,
+            "disk_info": [
+              {"mountpoint": "/"},
+              {"mountpoint": "/dev/shm"},
+              {"mountpoint": "/vagrant"},
+              {"mountpoint": "/"},
+              {"mountpoint": "/dev/shm"},
+              {"mountpoint": "/vagrant"}
+            ],
+            "public_host_name": "c6401.ambari.apache.org",
+            "host_name": "c6401.ambari.apache.org"
+          }
+        }
+      ]
+    }
+
+    clusterData = {
+      "cpu": 4,
+      "mapMemory": 3000,
+      "amMemory": 2000,
+      "reduceMemory": 2056,
+      "containers": 3,
+      "ramPerContainer": 256
+    }
+
+    # Services 1: YARN service with : (1). 'capacity scheduler' having only 'default' queue,
+    # (2). 'enable_hive_interactive' is ON, and (3). 'llap_queue_capacity' input is 0.
+    services_1 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+          }
+        ]
+      }, {
+          "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+          "StackServices": {
+            "service_name": "HIVE",
+            "service_version": "1.2.1.2.5",
+            "stack_name": "HDP",
+            "stack_version": "2.5"
+          },
+          "components": [
+            {
+              "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+              "StackServiceComponents": {
+                "advertise_version": "true",
+                "bulk_commands_display_name": "",
+                "bulk_commands_master_component_name": "",
+                "cardinality": "0-1",
+                "component_category": "MASTER",
+                "component_name": "HIVE_SERVER_INTERACTIVE",
+                "custom_commands": ["RESTART_LLAP"],
+                "decommission_allowed": "false",
+                "display_name": "HiveServer2 Interactive",
+                "has_bulk_commands_definition": "false",
+                "is_client": "false",
+                "is_master": "true",
+                "reassign_allowed": "false",
+                "recovery_enabled": "false",
+                "service_name": "HIVE",
+                "stack_name": "HDP",
+                "stack_version": "2.5",
+                "hostnames": ["c6401.ambari.apache.org"]
+              },
+              "dependencies": []
+            }
+          ]
+        }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.queues=default\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'true',
+              'llap_queue_capacity':'0'
+            }
+        },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+        }
+      }
+    }
+
+    # Services 2: YARN service with : (1). 'capacity scheduler' having only 'default' queue,
+    # (2). 'enable_hive_interactive' is OFF, and (3). 'llap_queue_capacity' input is 0.
+    services_2 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.queues=default\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 3: YARN service with : (1). 'capacity scheduler' having only 'default' queue,
+    # (2). 'enable_hive_interactive' is ON, and (3). 'llap_queue_capacity' input is 30.
+    services_3 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.queues=default\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'true',
+              'llap_queue_capacity':'40'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 4: YARN service with : (1). 'capacity scheduler' having 'llap' and 'default' queue at root level and
+    # (2). 'enable_hive_interactive' is OFF
+    services_4 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.queues=default,llap\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=80\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.root.llap.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.llap.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-capacity=20\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.llap.capacity=20\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 5: YARN service with : (1). 'capacity scheduler' having 'llap' and 'default' queue at root level and
+    # (2). 'enable_hive_interactive' is ON
+    services_5 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": 'yarn.scheduler.capacity.root.default.maximum-capacity=60\n'
+                                  'yarn.scheduler.capacity.root.accessible-node-labels=*\n'
+                                  'yarn.scheduler.capacity.root.capacity=100\n'
+                                  'yarn.scheduler.capacity.root.queues=default,llap\n'
+                                  'yarn.scheduler.capacity.maximum-applications=10000\n'
+                                  'yarn.scheduler.capacity.root.default.user-limit-factor=1\n'
+                                  'yarn.scheduler.capacity.root.default.state=RUNNING\n'
+                                  'yarn.scheduler.capacity.maximum-am-resource-percent=1\n'
+                                  'yarn.scheduler.capacity.root.default.acl_submit_applications=*\n'
+                                  'yarn.scheduler.capacity.root.default.capacity=60\n'
+                                  'yarn.scheduler.capacity.root.acl_administer_queue=*\n'
+                                  'yarn.scheduler.capacity.node-locality-delay=40\n'
+                                  'yarn.scheduler.capacity.queue-mappings-override.enable=false\n'
+                                  'yarn.scheduler.capacity.root.llap.user-limit-factor=1\n'
+                                  'yarn.scheduler.capacity.root.llap.state=RUNNING\n'
+                                  'yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n'
+                                  'yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n'
+                                  'yarn.scheduler.capacity.root.llap.maximum-capacity=40\n'
+                                  'yarn.scheduler.capacity.root.llap.capacity=40\n'
+                                  'yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n'
+                                  'yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n'
+                                  'yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1'
+
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'true',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 6: YARN service with : (1). 'capacity scheduler' having more than 2 queues and
+    # (2). 'enable_hive_interactive' is OFF
+    services_6= {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.maximum-am-resource-percent=0.2\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.resource-calculator=org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator\n"
+                                  "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.capacity=75\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.capacity=25\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.maximum-capacity=25\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.a2.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.a.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.a.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.queues=a1,a2\n"
+                                  "yarn.scheduler.capacity.root.default.a.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.b.maximum-capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.b.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.b.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.b.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.b.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.queues=a,b\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.queues=default"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 7: YARN service with 'capacity scheduler' empty and (2). 'enable_hive_interactive' is OFF
+    services_7= {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 8: YARN service with : (1). malformed 'capacity scheduler' and (2). 'enable_hive_interactive' is OFF
+    services_8= {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.default.a.a1.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.capacity=75\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.maximum-capacity=100\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 9: YARN service with : (1). 'capacity scheduler' having 'llap' and 'default' queue at root level and
+    # (2). 'llap' queue state is STOPPED and sized 0 % and (3). 'enable_hive_interactive' is OFF
+    services_9 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.queues=default,llap\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.root.llap.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.llap.state=STOPPED\n"
+                                  "yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-capacity=0\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.llap.capacity=0\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+    # Services 10: YARN service with : (1). 'capacity scheduler' having 'llap' and 'default' queue at root level and
+    # (2). 'llap' queue state is STOPPED and sized 0 % and (3). 'enable_hive_interactive' is ON
+    services_10 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.queues=default,llap\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.root.llap.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.llap.state=STOPPED\n"
+                                  "yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-capacity=0\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.llap.capacity=0\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'true',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+    # Services 11: YARN service with : (1). 'capacity scheduler' having 'llap' and 'default' queue at root level and
+    # (2). 'llap' queue state is STOPPED and sized 40 % and (3). 'enable_hive_interactive' is ON
+    services_11 = {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.queues=default,llap\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.maximum-am-resource-percent=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=80\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.root.llap.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.llap.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-capacity=20\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=80\n"
+                                  "yarn.scheduler.capacity.root.llap.capacity=20\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n"
+                                  "yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1\n"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'true',
+              'llap_queue_capacity':'40'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+
+
+    # Services 12: YARN service with : (1). 'capacity scheduler' having more than 2 queues out of which one queue
+    # is named 'llap' and (2). 'enable_hive_interactive' is OFF
+    services_12= {
+      "services": [{
+        "StackServices": {
+          "service_name": "YARN",
+        },
+        "Versions": {
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "StackServiceComponents": {
+              "component_name": "NODEMANAGER",
+              "hostnames": ["c6401.ambari.apache.org"]
+            }
+          }
+        ]
+      }, {
+        "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE",
+        "StackServices": {
+          "service_name": "HIVE",
+          "service_version": "1.2.1.2.5",
+          "stack_name": "HDP",
+          "stack_version": "2.5"
+        },
+        "components": [
+          {
+            "href": "/api/v1/stacks/HDP/versions/2.5/services/HIVE/components/HIVE_SERVER_INTERACTIVE",
+            "StackServiceComponents": {
+              "advertise_version": "true",
+              "bulk_commands_display_name": "",
+              "bulk_commands_master_component_name": "",
+              "cardinality": "0-1",
+              "component_category": "MASTER",
+              "component_name": "HIVE_SERVER_INTERACTIVE",
+              "custom_commands": ["RESTART_LLAP"],
+              "decommission_allowed": "false",
+              "display_name": "HiveServer2 Interactive",
+              "has_bulk_commands_definition": "false",
+              "is_client": "false",
+              "is_master": "true",
+              "reassign_allowed": "false",
+              "recovery_enabled": "false",
+              "service_name": "HIVE",
+              "stack_name": "HDP",
+              "stack_version": "2.5",
+              "hostnames": ["c6401.ambari.apache.org"]
+            },
+            "dependencies": []
+          }
+        ]
+      }
+      ],
+      "configurations": {
+        "capacity-scheduler": {
+          "properties": {
+            "capacity-scheduler": "yarn.scheduler.capacity.maximum-am-resource-percent=0.2\n"
+                                  "yarn.scheduler.capacity.maximum-applications=10000\n"
+                                  "yarn.scheduler.capacity.node-locality-delay=40\n"
+                                  "yarn.scheduler.capacity.queue-mappings-override.enable=false\n"
+                                  "yarn.scheduler.capacity.resource-calculator=org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator\n"
+                                  "yarn.scheduler.capacity.root.accessible-node-labels=*\n"
+                                  "yarn.scheduler.capacity.root.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.capacity=75\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.a1.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.capacity=25\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.maximum-capacity=25\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.llap.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.a.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.a.capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.a.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.a.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.a.queues=a1,llap\n"
+                                  "yarn.scheduler.capacity.root.default.a.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.a.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.acl_administer_queue=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.acl_submit_applications=*\n"
+                                  "yarn.scheduler.capacity.root.default.b.capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.b.maximum-capacity=50\n"
+                                  "yarn.scheduler.capacity.root.default.b.minimum-user-limit-percent=100\n"
+                                  "yarn.scheduler.capacity.root.default.b.ordering-policy=fifo\n"
+                                  "yarn.scheduler.capacity.root.default.b.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.b.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.default.capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                                  "yarn.scheduler.capacity.root.default.queues=a,b\n"
+                                  "yarn.scheduler.capacity.root.default.state=RUNNING\n"
+                                  "yarn.scheduler.capacity.root.default.user-limit-factor=1\n"
+                                  "yarn.scheduler.capacity.root.queues=default"
+          }
+        },
+        "hive-interactive-env":
+          {
+            'properties': {
+              'enable_hive_interactive': 'false',
+              'llap_queue_capacity':'0'
+            }
+          },
+        "hive-env":
+          {
+            'properties': {
+              'hive_user': 'hive'
+            }
+          }
+      }
+    }
+
+
+
+
+    # Expected config outputs.
+
+    # Expected capacity-scheduler with 'llap' (size:20) and 'default' queue at root level.
+    expected_capacity_scheduler_llap_queue_size_20 = {
+      "properties": {
+        "capacity-scheduler": 'yarn.scheduler.capacity.root.default.maximum-capacity=80\n'
+                              'yarn.scheduler.capacity.root.accessible-node-labels=*\n'
+                              'yarn.scheduler.capacity.root.capacity=100\n'
+                              'yarn.scheduler.capacity.root.queues=default,llap\n'
+                              'yarn.scheduler.capacity.maximum-applications=10000\n'
+                              'yarn.scheduler.capacity.root.default.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.default.state=RUNNING\n'
+                              'yarn.scheduler.capacity.maximum-am-resource-percent=1\n'
+                              'yarn.scheduler.capacity.root.default.acl_submit_applications=*\n'
+                              'yarn.scheduler.capacity.root.default.capacity=80\n'
+                              'yarn.scheduler.capacity.root.acl_administer_queue=*\n'
+                              'yarn.scheduler.capacity.node-locality-delay=40\n'
+                              'yarn.scheduler.capacity.queue-mappings-override.enable=false\n'
+                              'yarn.scheduler.capacity.root.llap.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.llap.state=RUNNING\n'
+                              'yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n'
+                              'yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-capacity=20\n'
+                              'yarn.scheduler.capacity.root.llap.capacity=20\n'
+                              'yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n'
+                              'yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1'
+
+      }
+    }
+
+    # Expected capacity-scheduler with 'llap' (size:40) and 'default' queue at root level.
+    expected_capacity_scheduler_llap_queue_size_40 = {
+      "properties": {
+        "capacity-scheduler": 'yarn.scheduler.capacity.root.default.maximum-capacity=60\n'
+                              'yarn.scheduler.capacity.root.accessible-node-labels=*\n'
+                              'yarn.scheduler.capacity.root.capacity=100\n'
+                              'yarn.scheduler.capacity.root.queues=default,llap\n'
+                              'yarn.scheduler.capacity.maximum-applications=10000\n'
+                              'yarn.scheduler.capacity.root.default.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.default.state=RUNNING\n'
+                              'yarn.scheduler.capacity.maximum-am-resource-percent=1\n'
+                              'yarn.scheduler.capacity.root.default.acl_submit_applications=*\n'
+                              'yarn.scheduler.capacity.root.default.capacity=60\n'
+                              'yarn.scheduler.capacity.root.acl_administer_queue=*\n'
+                              'yarn.scheduler.capacity.node-locality-delay=40\n'
+                              'yarn.scheduler.capacity.queue-mappings-override.enable=false\n'
+                              'yarn.scheduler.capacity.root.llap.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.llap.state=RUNNING\n'
+                              'yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n'
+                              'yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-capacity=40\n'
+                              'yarn.scheduler.capacity.root.llap.capacity=40\n'
+                              'yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n'
+                              'yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1'
+
+      }
+    }
+
+    # Expected capacity-scheduler with 'llap' state = STOPPED, cap = 0 % and 'default' queue cap to 100%.
+    expected_capacity_scheduler_llap_Stopped_size_0 = {
+      "properties": {
+        "capacity-scheduler": 'yarn.scheduler.capacity.root.default.maximum-capacity=100\n'
+                              'yarn.scheduler.capacity.root.accessible-node-labels=*\n'
+                              'yarn.scheduler.capacity.root.capacity=100\n'
+                              'yarn.scheduler.capacity.root.queues=default,llap\n'
+                              'yarn.scheduler.capacity.maximum-applications=10000\n'
+                              'yarn.scheduler.capacity.root.default.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.default.state=RUNNING\n'
+                              'yarn.scheduler.capacity.maximum-am-resource-percent=1\n'
+                              'yarn.scheduler.capacity.root.default.acl_submit_applications=*\n'
+                              'yarn.scheduler.capacity.root.default.capacity=100\n'
+                              'yarn.scheduler.capacity.root.acl_administer_queue=*\n'
+                              'yarn.scheduler.capacity.node-locality-delay=40\n'
+                              'yarn.scheduler.capacity.queue-mappings-override.enable=false\n'
+                              'yarn.scheduler.capacity.root.llap.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.llap.state=STOPPED\n'
+                              'yarn.scheduler.capacity.root.llap.ordering-policy=fifo\n'
+                              'yarn.scheduler.capacity.root.llap.minimum-user-limit-percent=100\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-capacity=0\n'
+                              'yarn.scheduler.capacity.root.llap.capacity=0\n'
+                              'yarn.scheduler.capacity.root.llap.acl_submit_applications=hive\n'
+                              'yarn.scheduler.capacity.root.llap.acl_administer_queue=hive\n'
+                              'yarn.scheduler.capacity.root.llap.maximum-am-resource-percent=1'
+
+      }
+    }
+
+    # Expected capacity-scheduler with only 'default' queue.
+    expected_capacity_scheduler_with_default_queue_only = {
+      "properties": {
+        "capacity-scheduler": 'yarn.scheduler.capacity.root.accessible-node-labels=*\n'
+                              'yarn.scheduler.capacity.maximum-am-resource-percent=1\n'
+                              'yarn.scheduler.capacity.root.capacity=100\n'
+                              'yarn.scheduler.capacity.root.default.state=RUNNING\n'
+                              'yarn.scheduler.capacity.node-locality-delay=40\n'
+                              'yarn.scheduler.capacity.root.queues=default\n'
+                              'yarn.scheduler.capacity.maximum-applications=10000\n'
+                              'yarn.scheduler.capacity.root.default.user-limit-factor=1\n'
+                              'yarn.scheduler.capacity.root.acl_administer_queue=*\n'
+                              'yarn.scheduler.capacity.root.default.acl_submit_applications=*\n'
+                              'yarn.scheduler.capacity.root.default.capacity=100\n'
+                              "yarn.scheduler.capacity.root.default.maximum-capacity=100\n"
+                              'yarn.scheduler.capacity.queue-mappings-override.enable=false\n'
+      }
+    }
+
+    # Expected capacity-scheduler as empty.
+    expected_capacity_scheduler_empty = {
+      "properties": {
+      }
+    }
+
+    # Expected 'hive_interactive_site' with (1). 'hive.llap.daemon.queue.name' set to 'llap' queue, and
+    # (2). 'hive.llap.daemon.queue.name' property_attributes set to : default and llap.
+    expected_hive_interactive_site_llap = {
+      "hive-interactive-site": {
+        "properties": {
+          "hive.llap.daemon.queue.name": "llap"
+        },
+        "property_attributes": {
+          "hive.llap.daemon.queue.name": {
+            "entries": [
+              {
+                "value": "default",
+                "label": "default"
+              },
+              {
+                "value": "llap",
+                "label": "llap"
+              }
+            ]
+          }
+        }
+      }
+    }
+
+    # Expected 'hive_interactive_site' with (1). 'hive.llap.daemon.queue.name' set to 'default' queue, and
+    # (2). 'hive.llap.daemon.queue.name' property_attributes set to : default.
+    expected_hive_interactive_site_default = {
+      "hive-interactive-site": {
+        "properties": {
+          "hive.llap.daemon.queue.name": "default"
+        },
+        "property_attributes": {
+          "hive.llap.daemon.queue.name": {
+            "entries": [
+              {
+                "value": "default",
+                "label": "default"
+              }
+            ]
+          }
+        }
+      }
+    }
+
+    # Expected 'hive_interactive_site' when no modifications are done.
+    expected_hive_interactive_site_empty = {
+      "hive-interactive-site": {
+        "properties": {
+        }
+      }
+    }
+
+    # Expected 'hive_interactive_env' with 'llap_queue_capacity' set to 20.
+    expected_llap_queue_capacity_20 = '20'
+
+    # Expected 'hive_interactive_env' with 'llap_queue_capacity' set to 40.
+    expected_llap_queue_capacity_40 = '40'
+
+
+
+
+    #################### Tests #####################
+
+
+    # Test 1 : (1). Only default queue exists in capacity-scheduler (2). enable_hive_interactive' is 'On' and
+    # 'llap_queue_capacity is 0.
+    configurations = {
+    }
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_1, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-env']['properties']['llap_queue_capacity'],
+                      expected_llap_queue_capacity_20)
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_queue_size_20['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+
+    # Test 2: (1). Only default queue exists in capacity-scheduler (2). enable_hive_interactive' is 'On' and
+    # 'llap_queue_capacity is 40.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_3, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'])
+    self.assertTrue('llap_queue_capacity' not in configurations['hive-interactive-env']['properties'])
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_queue_size_40['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+    # Test 3: (1). 'llap' (0%) and 'default' (100%) queues exists at leaf level in capacity-scheduler
+    #         (2). llap is state = STOPPED, (3). llap_queue_capacity = 0, and (4). enable_hive_interactive' is 'ON'.
+    #         Expected : llap queue state = RUNNING, llap_queue_capacity = 20
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_10, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-env']['properties']['llap_queue_capacity'],
+                      expected_llap_queue_capacity_20)
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_queue_size_20['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+
+    # Test 4: (1). 'llap' (20%) and 'default' (80%) queues exists at leaf level in capacity-scheduler
+    #         (2). llap is state = STOPPED, (3). llap_queue_capacity = 40, and (4). enable_hive_interactive' is 'ON'.
+    #         Expected : llap state goes RUNNING.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_11, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'])
+    self.assertTrue('llap_queue_capacity' not in configurations['hive-interactive-env']['properties'])
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_queue_size_40['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+
+
+    # Test 5: (1). 'llap' (20%) and 'default' (60%) queues exists at leaf level in capacity-scheduler
+    #         (2). llap is state = RUNNING, (3). llap_queue_capacity = 40, and (4). enable_hive_interactive' is 'ON'.
+    #         Expected : Existing llap queue's capacity in capacity-scheduler set to 40.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_11, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertEquals(configurations['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_llap['hive-interactive-site']['property_attributes']['hive.llap.daemon.queue.name'])
+    self.assertTrue('llap_queue_capacity' not in configurations['hive-interactive-env']['properties'])
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_queue_size_40['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+
+    # Test 6: (1). Only default queue exists in capacity-scheduler (2). enable_hive_interactive' is 'Off' and
+    #         'llap_queue_capacity is 0.
+    #         Expected : No changes
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_2, hosts)
+
+    # Check output
+    self.assertTrue('hive.llap.daemon.queue.name' not in configurations['hive-interactive-site']['properties'])
+    self.assertTrue('property_attributes' not in configurations['hive-interactive-site'])
+    self.assertTrue('hive-interactive-env' not in configurations)
+    self.assertEquals(configurations['capacity-scheduler']['properties'],expected_capacity_scheduler_empty['properties'])
+
+
+
+    # Test 7: (1). 'default' and 'llap' (State : RUNNING) queue exists at root level in capacity-scheduler, and
+    #         (2). enable_hive_interactive' is 'off'.
+    #         Expected : 'default' queue set to Size 100, 'llap' queue state set to STOPPED and sized to 0.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_4, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'],
+                      expected_hive_interactive_site_default['hive-interactive-site']['properties']['hive.llap.daemon.queue.name'])
+    self.assertFalse('property_attributes' in configurations['hive-interactive-site'])
+    self.assertFalse('hive-interactive-env' in configurations)
+
+    cap_sched_output_dict = convertToDict(configurations['capacity-scheduler']['properties']['capacity-scheduler'])
+    cap_sched_expected_dict = convertToDict(expected_capacity_scheduler_llap_Stopped_size_0['properties']['capacity-scheduler'])
+    self.assertEqual(cap_sched_output_dict, cap_sched_expected_dict)
+
+
+
+    # Test 8: (1). More than 2 queues at leaf level exists in capacity-scheduler (no queue is named 'llap')
+    #         (2). enable_hive_interactive' is 'off'.
+    #         Expected : No changes.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_6, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties'],
+                      expected_hive_interactive_site_empty['hive-interactive-site']['properties'])
+    self.assertEquals(configurations['capacity-scheduler']['properties'],
+                      expected_capacity_scheduler_empty['properties'])
+    self.assertFalse('hive-interactive-env' in configurations)
+
+
+
+    # Test 9: (1). More than 2 queues at leaf level exists in capacity-scheduler (one queue is named 'llap')
+    #         (2). enable_hive_interactive' is 'off'.
+    #         Expected : No changes.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_12, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties'],
+                      expected_hive_interactive_site_empty['hive-interactive-site']['properties'])
+    self.assertEquals(configurations['capacity-scheduler']['properties'],
+                      expected_capacity_scheduler_empty['properties'])
+    self.assertFalse('hive-interactive-env' in configurations)
+
+
+
+    # Test 10: (1). 'llap' (Cap: 0%, State: STOPPED) and 'default' (100%) queues exists at leaf level
+    #               in capacity-scheduler
+    #          (2). enable_hive_interactive' is 'off'.
+    #          Expected : No changes.
+    configurations = {
+    }
+
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_9, hosts)
+
+    # Check output
+    self.assertEquals(configurations['hive-interactive-site']['properties'],
+                      expected_hive_interactive_site_empty['hive-interactive-site']['properties'])
+    self.assertEquals(configurations['capacity-scheduler']['properties'],
+                      expected_capacity_scheduler_empty['properties'])
+    self.assertFalse('hive-interactive-env' in configurations)
+
+
+
+
+    # Test 11: capacity-scheduler not present as input in services.
+    #         Expected : No changes.
+    configurations = {
+    }
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_7, hosts)
+
+    # Check output
+    self.assertEquals(configurations['capacity-scheduler']['properties'],
+                      expected_capacity_scheduler_empty['properties'])
+    self.assertFalse('hive-interactive-env' in configurations)
+    self.assertEquals(configurations['hive-interactive-site']['properties'],
+                      expected_hive_interactive_site_empty['hive-interactive-site']['properties'])
+
+
+
+    # Test 12: capacity-scheduler malformed as input in services.
+    #         Expected : No changes.
+    configurations = {
+    }
+    self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services_8, hosts)
+
+    # Check output
+    self.assertEquals(configurations['capacity-scheduler']['properties'],
+                      expected_capacity_scheduler_empty['properties'])
+    self.assertFalse('hive-interactive-env' in configurations)
+    self.assertEquals(configurations['hive-interactive-site']['properties'],
+                      expected_hive_interactive_site_empty['hive-interactive-site']['properties'])
+
+
+
+"""
+Helper method to convert string of key-values to dict.
+"""
+def convertToDict(properties):
+  capacitySchedulerProperties = dict()
+  properties = str(properties).split('\n')
+  if properties:
+    for property in properties:
+      key, sep, value = property.partition("=")
+      if key:
+        capacitySchedulerProperties[key] = value
+  return capacitySchedulerProperties
\ No newline at end of file


[2/2] ambari git commit: AMBARI-15876. HiveServerInteractive. Stack advisor work for adding and disabling LLAP queue when Interactive query is turned on and off respectively.

Posted by sw...@apache.org.
AMBARI-15876. HiveServerInteractive. Stack advisor work for adding and disabling LLAP queue when Interactive query is turned on and off respectively.


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

Branch: refs/heads/trunk
Commit: a224f2657bfe17d6047fa7dbb6dc5599fc964567
Parents: 08a9332
Author: swapan <sw...@apache.org>
Authored: Wed Apr 13 17:53:02 2016 -0700
Committer: swapan <sw...@apache.org>
Committed: Fri Apr 15 16:58:16 2016 -0700

----------------------------------------------------------------------
 .../HIVE/configuration/hive-interactive-env.xml |    6 +
 .../configuration/hive-interactive-site.xml     |   12 +-
 .../YARN/configuration/capacity-scheduler.xml   |   35 +
 .../stacks/HDP/2.5/services/stack_advisor.py    |  391 ++++-
 .../stacks/2.5/common/test_stack_advisor.py     | 1597 +++++++++++++++++-
 5 files changed, 1980 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a224f265/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-env.xml
index d518c8b..88541bd 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-env.xml
@@ -62,6 +62,12 @@
       <maximum>100</maximum>
       <increment-step>1</increment-step>
     </value-attributes>
+    <depends-on>
+      <property>
+        <type>hive-interactive-env</type>
+        <name>enable_hive_interactive</name>
+      </property>
+    </depends-on>
   </property>
   <property>
     <name>num_llap_nodes</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a224f265/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml
index ba46f00..f656aaf 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml
@@ -288,6 +288,16 @@ limitations under the License.
       </entries>
       <selection-cardinality>1</selection-cardinality>
     </value-attributes>
+    <depends-on>
+      <property>
+        <type>capacity-scheduler</type>
+        <name>yarn.scheduler.capacity.root.queues</name>
+      </property>
+      <property>
+        <type>hive-interactive-env</type>
+        <name>enable_hive_interactive</name>
+      </property>
+    </depends-on>
   </property>
 
   <property>
@@ -347,7 +357,7 @@ limitations under the License.
 
   <property>
     <name>hive.llap.daemon.service.hosts</name>
-    <value>@llap0</value>
+    <value>@{cluster_name}</value>
   </property>
 
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a224f265/ambari-server/src/main/resources/stacks/HDP/2.5/services/YARN/configuration/capacity-scheduler.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/services/YARN/configuration/capacity-scheduler.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/services/YARN/configuration/capacity-scheduler.xml
new file mode 100644
index 0000000..b36a1f1
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/services/YARN/configuration/capacity-scheduler.xml
@@ -0,0 +1,35 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<configuration supports_final="false" supports_adding_forbidden="true">
+
+  <property>
+    <name>capacity-scheduler</name>
+    <depends-on>
+      <property>
+        <type>hive-interactive-env</type>
+        <name>enable_hive_interactive</name>
+      </property>
+      <property>
+        <type>hive-interactive-env</type>
+        <name>llap_queue_capacity</name>
+      </property>
+    </depends-on>
+    <property-type>DONT_ADD_ON_UPGRADE</property-type>
+  </property>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/a224f265/ambari-server/src/main/resources/stacks/HDP/2.5/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.5/services/stack_advisor.py
index 7407da3..6680611 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/services/stack_advisor.py
@@ -17,8 +17,14 @@ See the License for the specific language governing permissions and
 limitations under the License.
 """
 
+from resource_management.core.logger import Logger
 
 class HDP25StackAdvisor(HDP24StackAdvisor):
+
+  def __init__(self):
+    super(HDP25StackAdvisor, self).__init__()
+    Logger.initialize_logger()
+
   def createComponentLayoutRecommendations(self, services, hosts):
     parentComponentLayoutRecommendations = super(HDP25StackAdvisor, self).createComponentLayoutRecommendations(
       services, hosts)
@@ -26,17 +32,13 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
 
   def getComponentLayoutValidations(self, services, hosts):
     parentItems = super(HDP25StackAdvisor, self).getComponentLayoutValidations(services, hosts)
-    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
-    componentsListList = [service["components"] for service in services["services"]]
-    componentsList = [item["StackServiceComponents"] for sublist in componentsListList for item in sublist]
     childItems = []
 
-    if "HIVE" in servicesList:
-      hsi_hosts = self.__getHosts(componentsList, "HIVE_SERVER_INTERACTIVE")
-      if len(hsi_hosts) > 1:
-        message = "Only one host can install HIVE_SERVER_INTERACTIVE. "
-        childItems.append(
-          {"type": 'host-component', "level": 'ERROR', "message": message, "component-name": 'HIVE_SERVER_INTERACTIVE'})
+    hsi_hosts = self.__getHostsForComponent(services, "HIVE", "HIVE_SERVER_INTERACTIVE")
+    if len(hsi_hosts) > 1:
+      message = "Only one host can install HIVE_SERVER_INTERACTIVE. "
+      childItems.append(
+        {"type": 'host-component', "level": 'ERROR', "message": message, "component-name": 'HIVE_SERVER_INTERACTIVE'})
 
     parentItems.extend(childItems)
     return parentItems
@@ -51,33 +53,28 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
 
   def validateHiveInteractiveEnvConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
     hive_site_env_properties = getSiteProperties(configurations, "hive-interactive-env")
-    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
-    componentsListList = [service["components"] for service in services["services"]]
-    componentsList = [item["StackServiceComponents"] for sublist in componentsListList for item in sublist]
     validationItems = []
-
-    if "HIVE" in servicesList:
-      hsi_hosts = self.__getHosts(componentsList, "HIVE_SERVER_INTERACTIVE")
-      if len(hsi_hosts) > 0:
-        # HIVE_SERVER_INTERACTIVE is mapped to a host
-        if 'enable_hive_interactive' not in hive_site_env_properties or (
-                'enable_hive_interactive' in hive_site_env_properties and hive_site_env_properties[
-              'enable_hive_interactive'].lower() != 'true'):
-          validationItems.append({"config-name": "enable_hive_interactive",
-                                  "item": self.getWarnItem(
-                                    "HIVE_SERVER_INTERACTIVE requires enable_hive_interactive in hive-interactive-env set to true.")})
-        if 'hive_server_interactive_host' in hive_site_env_properties:
-          hsi_host = hsi_hosts[0]
-          if hive_site_env_properties['hive_server_interactive_host'].lower() != hsi_host.lower():
-            validationItems.append({"config-name": "hive_server_interactive_host",
-                                    "item": self.getWarnItem(
-                                      "HIVE_SERVER_INTERACTIVE requires hive_server_interactive_host in hive-interactive-env set to its host name.")})
-          pass
-        if 'hive_server_interactive_host' not in hive_site_env_properties:
+    hsi_hosts = self.__getHostsForComponent(services, "HIVE", "HIVE_SERVER_INTERACTIVE")
+    if len(hsi_hosts) > 0:
+      # HIVE_SERVER_INTERACTIVE is mapped to a host
+      if 'enable_hive_interactive' not in hive_site_env_properties or (
+            'enable_hive_interactive' in hive_site_env_properties and hive_site_env_properties[
+          'enable_hive_interactive'].lower() != 'true'):
+        validationItems.append({"config-name": "enable_hive_interactive",
+                                "item": self.getWarnItem(
+                                  "HIVE_SERVER_INTERACTIVE requires enable_hive_interactive in hive-interactive-env set to true.")})
+      if 'hive_server_interactive_host' in hive_site_env_properties:
+        hsi_host = hsi_hosts[0]
+        if hive_site_env_properties['hive_server_interactive_host'].lower() != hsi_host.lower():
           validationItems.append({"config-name": "hive_server_interactive_host",
                                   "item": self.getWarnItem(
                                     "HIVE_SERVER_INTERACTIVE requires hive_server_interactive_host in hive-interactive-env set to its host name.")})
-          pass
+        pass
+      if 'hive_server_interactive_host' not in hive_site_env_properties:
+        validationItems.append({"config-name": "hive_server_interactive_host",
+                                "item": self.getWarnItem(
+                                  "HIVE_SERVER_INTERACTIVE requires hive_server_interactive_host in hive-interactive-env set to its host name.")})
+        pass
 
     else:
       # no  HIVE_SERVER_INTERACTIVE
@@ -92,7 +89,6 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
     validationProblems = self.toConfigurationValidationProblems(validationItems, "hdfs-site")
     return validationProblems
 
-
   def getServiceConfigurationRecommenderDict(self):
     parentRecommendConfDict = super(HDP25StackAdvisor, self).getServiceConfigurationRecommenderDict()
     childRecommendConfDict = {
@@ -102,34 +98,300 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
     parentRecommendConfDict.update(childRecommendConfDict)
     return parentRecommendConfDict
 
-
   def recommendHIVEConfigurations(self, configurations, clusterData, services, hosts):
-    super(HDP23StackAdvisor, self).recommendHIVEConfigurations(configurations, clusterData, services, hosts)
+    super(HDP25StackAdvisor, self).recommendHIVEConfigurations(configurations, clusterData, services, hosts)
     putHiveInteractiveEnvProperty = self.putProperty(configurations, "hive-interactive-env", services)
-    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
-    componentsListList = [service["components"] for service in services["services"]]
-    componentsList = [item["StackServiceComponents"] for sublist in componentsListList for item in sublist]
 
-    if "HIVE" in servicesList:
-      hsi_hosts = self.__getHosts(componentsList, "HIVE_SERVER_INTERACTIVE")
-      if len(hsi_hosts) > 0:
-        hsi_host = hsi_hosts[0]
-        putHiveInteractiveEnvProperty('enable_hive_interactive', 'true')
-        putHiveInteractiveEnvProperty('hive_server_interactive_host', hsi_host)
-      else:
-        putHiveInteractiveEnvProperty('enable_hive_interactive', 'false')
-      pass
+    # For 'Hive Server Interactive', if the component exists.
+    hsi_hosts = self.__getHostsForComponent(services, "HIVE", "HIVE_SERVER_INTERACTIVE")
+    if len(hsi_hosts) > 0:
+      hsi_host = hsi_hosts[0]
+      putHiveInteractiveEnvProperty('enable_hive_interactive', 'true')
+      putHiveInteractiveEnvProperty('hive_server_interactive_host', hsi_host)
+
+      if 'hive.llap.zk.sm.connectionString' in services['configurations']['hive-interactive-site']['properties']:
+        # Fill the property 'hive.llap.zk.sm.connectionString' required by Hive Server Interactive (HiveServer2)
+        zookeeper_host_port = self.getZKHostPortString(services)
+        if zookeeper_host_port:
+          putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
+          putHiveInteractiveSiteProperty("hive.llap.zk.sm.connectionString", zookeeper_host_port)
+
+      # Update 'hive.llap.daemon.queue.name' if capacity scheduler is changed.
+      if 'hive.llap.daemon.queue.name' in services['configurations']['hive-interactive-site']['properties']:
+        self.setLlapDaemonQueueName(services, configurations)
+    else:
+      putHiveInteractiveEnvProperty('enable_hive_interactive', 'false')
     pass
 
-    if 'hive-interactive-site' in services['configurations'] and \
-      services['configurations']['hive-interactive-site']['properties']['hive.llap.zk.sm.connectionString']:
 
-      # Fill the property 'hive.llap.zk.sm.connectionString' required by Hive Server Interactive (HiveServer2)
-      zookeeper_host_port = self.getZKHostPortString(services)
-      if zookeeper_host_port:
-        putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
-        putHiveInteractiveSiteProperty("hive.llap.zk.sm.connectionString", zookeeper_host_port)
 
+  def recommendYARNConfigurations(self, configurations, clusterData, services, hosts):
+    super(HDP25StackAdvisor, self).recommendYARNConfigurations(configurations, clusterData, services, hosts)
+
+    # Queue 'llap' creation/removal logic (Used by Hive Interactive server and associated LLAP)
+    hsi_hosts = self.__getHostsForComponent(services, "HIVE", "HIVE_SERVER_INTERACTIVE")
+    if len(hsi_hosts) > 0:
+      if 'hive-interactive-env' in services['configurations'] and \
+          'enable_hive_interactive' in services['configurations']['hive-interactive-env']['properties']:
+        enable_hive_interactive = services['configurations']['hive-interactive-env']['properties']['enable_hive_interactive']
+        llap_queue_name = 'llap'
+
+        # Hive Server interactive is already added or getting added
+        if enable_hive_interactive == 'true':
+          self.checkAndManageLlapQueue(services, configurations, llap_queue_name)
+        else:  # When Hive Interactive Server is in 'off/removed' state.
+          self.checkAndStopLlapQueue(services, configurations, llap_queue_name)
+
+  """
+  Checks and (1). Creates 'llap' queue if only 'default' queue exist at leaf level and is consuming 100% capacity OR
+             (2). Updates 'llap' queue capacity and state, if 'llap' queue exists.
+  """
+  def checkAndManageLlapQueue(self, services, configurations, llap_queue_name):
+    DEFAULT_LLAP_QUEUE_CAP_PERCENT = 20
+    putHiveInteractiveEnvProperty = self.putProperty(configurations, "hive-interactive-env", services)
+    putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
+    putCapSchedProperty = self.putProperty(configurations, "capacity-scheduler", services)
+
+    capacitySchedulerProperties = self.getCapacitySchedulerProperties(services)
+
+    if capacitySchedulerProperties:
+      # Get the llap Cluster percentage used for 'llap' Queue creation
+      if 'llap_queue_capacity' in services['configurations']['hive-interactive-env']['properties']:
+        llapSliderCapPercentage = int(
+          services['configurations']['hive-interactive-env']['properties']['llap_queue_capacity'])
+        if llapSliderCapPercentage not in range(1,101):
+          Logger.debug("Adjusting HIVE 'llap_queue_capacity' from {0}% to {1}%".format(llapSliderCapPercentage, DEFAULT_LLAP_QUEUE_CAP_PERCENT))
+          llapSliderCapPercentage = DEFAULT_LLAP_QUEUE_CAP_PERCENT  # Set the default value to 20.
+          putHiveInteractiveEnvProperty('llap_queue_capacity', llapSliderCapPercentage)
+      else:
+        Logger.error("Problem retrieving LLAP Queue Capacity. Skipping creating {0} queue".format(llap_queue_name))
+        return
+
+      leafQueueNames = self.getAllYarnLeafQueues(capacitySchedulerProperties)
+      capSchedConfigKeys = capacitySchedulerProperties.keys()
+
+      yarn_default_queue_capacity = -1
+      if 'yarn.scheduler.capacity.root.capacity' in capSchedConfigKeys:
+        yarn_default_queue_capacity = capacitySchedulerProperties.get('yarn.scheduler.capacity.root.capacity')
+
+      # Get 'llap' queue state
+      currLlapQueueState = ''
+      if 'yarn.scheduler.capacity.root.'+llap_queue_name+'.state' in capSchedConfigKeys:
+        currLlapQueueState = capacitySchedulerProperties.get('yarn.scheduler.capacity.root.'+llap_queue_name+'.state')
+
+      # Get 'llap' queue capacity
+      currLlapQueueCap = -1
+      if 'yarn.scheduler.capacity.root.'+llap_queue_name+'.capacity' in capSchedConfigKeys:
+        currLlapQueueCap = capacitySchedulerProperties.get('yarn.scheduler.capacity.root.'+llap_queue_name+'.capacity')
+
+      updated_cap_sched_configs = ''
+
+      """
+      We create OR "modify 'llap' queue 'state and/or capacity' " based on below conditions:
+       - if only 1 queue exists at root level and is 'default' queue and has 100% cap -> Create 'llap' queue,  OR
+       - if 2 queues exists at root level ('llap' and 'default') :
+           - 'llap' queue state is STOPPED -> Modify 'llap' queue state to RUNNING, adjust capacity, OR
+           - 'llap' queue state is RUNNING and 'llap_queue_capacity' prop != 'llap' queue current running capacity ->
+              Modify 'llap' queue capacity to 'llap_queue_capacity'
+      """
+      if 'default' in leafQueueNames and \
+        ((len(leafQueueNames) == 1 and int(yarn_default_queue_capacity) == 100) or \
+        ((len(leafQueueNames) == 2 and llap_queue_name in leafQueueNames) and \
+           (currLlapQueueState == 'STOPPED' or (currLlapQueueState == 'RUNNING' and currLlapQueueCap != llapSliderCapPercentage)))):
+        adjusted_default_queue_cap = str(int(yarn_default_queue_capacity) - llapSliderCapPercentage)
+        for prop, val in capacitySchedulerProperties.items():
+          if llap_queue_name not in prop:
+            if prop == 'yarn.scheduler.capacity.root.queues':
+              updated_cap_sched_configs = updated_cap_sched_configs \
+                                          + prop + "=default,llap\n"
+            elif prop == 'yarn.scheduler.capacity.root.default.capacity':
+              updated_cap_sched_configs = updated_cap_sched_configs \
+                                          + prop + "=" + adjusted_default_queue_cap + "\n"
+            elif prop == 'yarn.scheduler.capacity.root.default.maximum-capacity':
+              updated_cap_sched_configs = updated_cap_sched_configs \
+                                          + prop + "=" + adjusted_default_queue_cap + "\n"
+            elif prop.startswith('yarn.') and '.llap.' not in prop:
+              updated_cap_sched_configs = updated_cap_sched_configs + prop + "=" + val + "\n"
+
+        llapSliderCapPercentage = str(llapSliderCapPercentage)
+        hive_user = '*'  # Open to all
+        if 'hive_user' in services['configurations']['hive-env']['properties']:
+          hive_user = services['configurations']['hive-env']['properties']['hive_user']
+
+        # Now, append the 'llap' queue related properties
+        updated_cap_sched_configs = updated_cap_sched_configs \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".user-limit-factor=1\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".state=RUNNING\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".ordering-policy=fifo\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".minimum-user-limit-percent=100\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".maximum-capacity=" \
+                                    + llapSliderCapPercentage + "\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".capacity=" \
+                                    + llapSliderCapPercentage + "\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".acl_submit_applications=" \
+                                    + hive_user + "\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".acl_administer_queue=" \
+                                    + hive_user + "\n" \
+                                    + "yarn.scheduler.capacity.root." + llap_queue_name + ".maximum-am-resource-percent=1"
+
+        if updated_cap_sched_configs:
+          putCapSchedProperty("capacity-scheduler", updated_cap_sched_configs)
+          if len(leafQueueNames) == 1: # 'llap' queue didn't exist before
+            Logger.info("Created YARN Queue : '{0}' with capacity : {1}%. Adjusted default queue capacity to : {2}%" \
+                      .format(llap_queue_name, llapSliderCapPercentage, adjusted_default_queue_cap))
+          else: # Queue existed, only adjustments done.
+            Logger.info("Adjusted YARN Queue : '{0}'. Current capacity : {1}%. State: RUNNING.".format(llap_queue_name, llapSliderCapPercentage))
+            Logger.info("Adjusted 'default' queue capacity to : {0}%".format(adjusted_default_queue_cap))
+
+          # Update Hive 'hive.llap.daemon.queue.name' prop to use 'llap' queue.
+          putHiveInteractiveSiteProperty('hive.llap.daemon.queue.name', 'llap')
+          # Update 'hive.llap.daemon.queue.name' prop combo entries.
+          self.setLlapDaemonQueueName(services, configurations)
+      else:
+        Logger.debug("Not creating {0} queue. Current YARN queues : {1}".format(llap_queue_name, list(leafQueueNames)))
+    else:
+      Logger.error("Couldn't retrieve 'capacity-scheduler' properties while doing YARN queue adjustment for Hive Server Interactive.")
+
+  """
+  Checks and sees (1). If only two leaf queues exist at root level, namely: 'default' and 'llap',
+              and (2). 'llap' is in RUNNING state.
+
+  If yes, performs the following actions:   (1). 'llap' queue state set to STOPPED,
+                                            (2). 'llap' queue capacity set to 0 %,
+                                            (3). 'default' queue capacity set to 100 %
+  """
+  def checkAndStopLlapQueue(self, services, configurations, llap_queue_name):
+    putCapSchedProperty = self.putProperty(configurations, "capacity-scheduler", services)
+    putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
+
+    capacitySchedulerProperties = self.getCapacitySchedulerProperties(services)
+
+    updated_default_queue_configs = ''
+    updated_llap_queue_configs = ''
+    if capacitySchedulerProperties:
+      # Get all leaf queues.
+      leafQueueNames = self.getAllYarnLeafQueues(capacitySchedulerProperties)
+
+      if len(leafQueueNames) == 2 and llap_queue_name in leafQueueNames and 'default' in leafQueueNames:
+        # Get 'llap' queue state
+        currLlapQueueState = 'STOPPED'
+        if 'yarn.scheduler.capacity.root.'+llap_queue_name+'.state' in capacitySchedulerProperties.keys():
+          currLlapQueueState = capacitySchedulerProperties.get('yarn.scheduler.capacity.root.'+llap_queue_name+'.state')
+        else:
+          Logger.error("{0} queue 'state' property not present in capacity scheduler. Skipping adjusting queues.".format(llap_queue_name))
+          return
+
+        if currLlapQueueState == 'RUNNING':
+          DEFAULT_MAX_CAPACITY = '100'
+          for prop, val in capacitySchedulerProperties.items():
+            # Update 'default' related configs in 'updated_cap_sched_configs'
+            if llap_queue_name not in prop:
+              if prop == 'yarn.scheduler.capacity.root.default.capacity':
+                # Set 'default' capacity back to maximum val
+                updated_default_queue_configs = updated_default_queue_configs \
+                                            + prop + "="+DEFAULT_MAX_CAPACITY + "\n"
+              elif prop == 'yarn.scheduler.capacity.root.default.maximum-capacity':
+                # Set 'default' max. capacity back to maximum val
+                updated_default_queue_configs = updated_default_queue_configs \
+                                            + prop + "="+DEFAULT_MAX_CAPACITY + "\n"
+              elif prop.startswith('yarn.'):
+                updated_default_queue_configs = updated_default_queue_configs + prop + "=" + val + "\n"
+            else: # Update 'llap' related configs in 'updated_cap_sched_configs'
+              if prop == 'yarn.scheduler.capacity.root.'+llap_queue_name+'.state':
+                updated_llap_queue_configs = updated_llap_queue_configs \
+                                            + prop + "=STOPPED\n"
+              elif prop == 'yarn.scheduler.capacity.root.'+llap_queue_name+'.capacity':
+                updated_llap_queue_configs = updated_llap_queue_configs \
+                                            + prop + "=0\n"
+              elif prop == 'yarn.scheduler.capacity.root.'+llap_queue_name+'.maximum-capacity':
+                updated_llap_queue_configs = updated_llap_queue_configs \
+                                            + prop + "=0\n"
+              elif prop.startswith('yarn.'):
+                updated_llap_queue_configs = updated_llap_queue_configs + prop + "=" + val + "\n"
+        else:
+          Logger.debug("{0} queue state is : {1}. Skipping adjusting queues.".format(llap_queue_name, currLlapQueueState))
+          return
+
+        if updated_default_queue_configs and updated_llap_queue_configs:
+          putCapSchedProperty("capacity-scheduler", updated_default_queue_configs+updated_llap_queue_configs)
+          Logger.info("Changed YARN '{0}' queue state to 'STOPPED', and capacity to 0%. Adjusted 'default' queue capacity to : {1}%" \
+            .format(llap_queue_name, DEFAULT_MAX_CAPACITY))
+
+          # Update Hive 'hive.llap.daemon.queue.name' prop to use 'default' queue.
+          putHiveInteractiveSiteProperty('hive.llap.daemon.queue.name', 'default')
+      else:
+        Logger.debug("Not removing '{0}' queue as number of Queues not equal to 2. Current YARN queues : {1}".format(llap_queue_name, list(leafQueueNames)))
+    else:
+      Logger.error("Couldn't retrieve 'capacity-scheduler' properties while doing YARN queue adjustment for Hive Server Interactive.")
+
+  """
+  Checks and sets the 'Hive Server Interactive' 'hive.llap.daemon.queue.name' config.
+  """
+  def setLlapDaemonQueueName(self, services, configurations):
+    putHiveInteractiveSitePropertyAttribute = self.putPropertyAttribute(configurations, "hive-interactive-site")
+    capacitySchedulerProperties = dict()
+
+    # Read 'capacity-scheduler' from configurations if we modified and added recommendation to it, as part of current
+    # StackAdvisor invocation.
+    if 'capacity-scheduler' in configurations and \
+        'capacity-scheduler' in configurations['capacity-scheduler']['properties']:
+      properties = str(configurations['capacity-scheduler']['properties']['capacity-scheduler']).split('\n')
+      for property in properties:
+        key, sep, value = property.partition("=")
+        capacitySchedulerProperties[key] = value
+    else: # read from input : services
+      capacitySchedulerProperties = self.getCapacitySchedulerProperties(services)
+
+    leafQueueNames = self.getAllYarnLeafQueues(capacitySchedulerProperties)
+    if leafQueueNames:
+      leafQueues = [{"label": str(queueName), "value": queueName} for queueName in leafQueueNames]
+      leafQueues = sorted(leafQueues, key=lambda q:q['value'])
+      putHiveInteractiveSitePropertyAttribute("hive.llap.daemon.queue.name", "entries", leafQueues)
+    else:
+      Logger.error("Problem retrieving YARN queues. Skipping updating HIVE Server Interactve "
+                   "'hive.server2.tez.default.queues' property.")
+
+  """
+  Gets all YARN leaf queues.
+  """
+  def getAllYarnLeafQueues(self, capacitySchedulerProperties):
+    config_list = capacitySchedulerProperties.keys()
+    yarn_queues = []
+    leafQueueNames = set()
+    if 'yarn.scheduler.capacity.root.queues' in config_list:
+      yarn_queues = capacitySchedulerProperties.get('yarn.scheduler.capacity.root.queues')
+
+    if yarn_queues:
+      toProcessQueues = yarn_queues.split(",")
+      while len(toProcessQueues) > 0:
+        queue = toProcessQueues.pop()
+        queueKey = "yarn.scheduler.capacity.root." + queue + ".queues"
+        if queueKey in capacitySchedulerProperties:
+          # If parent queue, add children
+          subQueues = capacitySchedulerProperties[queueKey].split(",")
+          for subQueue in subQueues:
+            toProcessQueues.append(queue + "." + subQueue)
+        else:
+          # Leaf queue
+          queueName = queue.split(".")[-1]
+          leafQueueNames.add(queueName)
+    return leafQueueNames
+
+  """
+  Returns the dictionary of 'capacity-scheduler' related configs.
+  """
+  def getCapacitySchedulerProperties(self, services):
+    capacitySchedulerProperties = dict()
+    if "capacity-scheduler" in services['configurations']:
+      if "capacity-scheduler" in services['configurations']["capacity-scheduler"]["properties"]:
+        properties = str(services['configurations']["capacity-scheduler"]["properties"]["capacity-scheduler"])\
+          .split('\n')
+
+        if properties:
+          for property in properties:
+            key, sep, value = property.partition("=")
+            capacitySchedulerProperties[key] = value
+    return capacitySchedulerProperties
 
   def recommendRangerConfigurations(self, configurations, clusterData, services, hosts):
     super(HDP25StackAdvisor, self).recommendRangerConfigurations(configurations, clusterData, services, hosts)
@@ -148,7 +410,7 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
       kafka_hosts = self.getHostNamesWithComponent("KAFKA", "KAFKA_BROKER", services)
       kafka_port = '6667'
       if 'kafka-broker' in services['configurations'] and (
-            'port' in services['configurations']['kafka-broker']['properties']):
+          'port' in services['configurations']['kafka-broker']['properties']):
         kafka_port = services['configurations']['kafka-broker']['properties']['port']
       kafka_host_port = []
       for i in range(len(kafka_hosts)):
@@ -159,7 +421,18 @@ class HDP25StackAdvisor(HDP24StackAdvisor):
     else:
       putTagsyncAppProperty('atlas.kafka.bootstrap.servers', 'localhost:2181')
 
-
-  def __getHosts(self, componentsList, componentName):
-    return [component["hostnames"] for component in componentsList if component["component_name"] == componentName][0]
-
+  """
+  Returns the host(s) on which a requested service's component is hosted.
+  Parameters :
+    services : Configuration information for the cluster
+    serviceName : Passed-in service in consideration
+    componentName : Passed-in component in consideration
+  """
+  def __getHostsForComponent(self, services, serviceName, componentName):
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+    componentsListList = [service["components"] for service in services["services"]]
+    componentsList = [item["StackServiceComponents"] for sublist in componentsListList for item in sublist]
+    hosts_for_component = []
+    if serviceName in servicesList:
+      hosts_for_component = [component["hostnames"] for component in componentsList if component["component_name"] == componentName][0]
+    return hosts_for_component
\ No newline at end of file