You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/05/18 21:27:29 UTC

ambari git commit: AMBARI-11218. Hive alerts need to use either legacy or new conf locations (ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk 220a5a271 -> 2015be59a


AMBARI-11218. Hive alerts need to use either legacy or new conf locations (ncole)


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

Branch: refs/heads/trunk
Commit: 2015be59acced0845a614e68bba3ed97a2552af7
Parents: 220a5a2
Author: Nate Cole <nc...@hortonworks.com>
Authored: Mon May 18 11:44:36 2015 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon May 18 15:27:21 2015 -0400

----------------------------------------------------------------------
 .../common-services/HIVE/0.12.0.2.0/alerts.json  |  9 ++++++++-
 .../package/alerts/alert_hive_metastore.py       | 19 +++++++++++++++++--
 .../package/alerts/alert_webhcat_server.py       | 17 +++++++++++++++--
 3 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2015be59/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/alerts.json b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/alerts.json
index 2bdc532..55e3f78 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/alerts.json
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/alerts.json
@@ -88,6 +88,13 @@
           "path": "HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py",
           "parameters": [
             {
+              "name": "default.smoke.user",
+              "display_name": "Default Smoke User",
+              "value": "ambari-qa",
+              "type": "STRING",
+              "description": "The user that will run the Hive commands if not specified in cluster-env/smokeuser"
+            },
+            {
               "name": "connection.timeout",
               "display_name": "Connection Timeout",
               "value": 5.0,
@@ -101,4 +108,4 @@
       }    
     ]
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2015be59/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
index a7ed54f..b6bc69d 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
@@ -18,6 +18,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 """
 
+import os
 import socket
 import time
 
@@ -49,6 +50,13 @@ SMOKEUSER_PRINCIPAL_DEFAULT = 'ambari-qa@EXAMPLE.COM'
 SMOKEUSER_SCRIPT_PARAM_KEY = 'default.smoke.user'
 SMOKEUSER_DEFAULT = 'ambari-qa'
 
+HIVE_CONF_DIR = '/usr/hdp/current/hive-metastore/conf/conf.server'
+HIVE_CONF_DIR_LEGACY = '/etc/hive/conf.server'
+
+HIVE_BIN_DIR = '/usr/hdp/current/hive-metastore/bin'
+HIVE_BIN_DIR_LEGACY = '/usr/lib/hive/bin'
+
+
 def get_tokens():
   """
   Returns a tuple of tokens in the format {{site/property}} that will be used
@@ -130,7 +138,14 @@ def execute(configurations={}, parameters={}, host_name=None):
       if host_name in uri:
         metastore_uri = uri
 
-    cmd = format("export HIVE_CONF_DIR='/etc/hive/conf.server/' ; "
+    conf_dir = HIVE_CONF_DIR_LEGACY
+    bin_dir = HIVE_BIN_DIR_LEGACY
+
+    if os.path.exists(HIVE_CONF_DIR):
+      conf_dir = HIVE_CONF_DIR
+      bin_dir = HIVE_BIN_DIR
+
+    cmd = format("export HIVE_CONF_DIR='{conf_dir}' ; "
                  "hive --hiveconf hive.metastore.uris={metastore_uri}\
                  --hiveconf hive.metastore.client.connect.retry.delay=1s\
                  --hiveconf hive.metastore.failure.retries=1\
@@ -142,7 +157,7 @@ def execute(configurations={}, parameters={}, host_name=None):
 
     try:
       Execute(cmd, user=smokeuser,
-        path=["/bin/", "/usr/bin/", "/usr/lib/hive/bin/", "/usr/sbin/"],
+        path=["/bin/", "/usr/bin/", "/usr/sbin/", bin_dir],
         timeout=30 )
 
       total_time = time.time() - start_time

http://git-wip-us.apache.org/repos/asf/ambari/blob/2015be59/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py
index 7ee375e..df93633 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_webhcat_server.py
@@ -57,13 +57,18 @@ CONNECTION_TIMEOUT_KEY = 'connection.timeout'
 CONNECTION_TIMEOUT_DEFAULT = 5.0
 CURL_CONNECTION_TIMEOUT_DEFAULT = str(int(CONNECTION_TIMEOUT_DEFAULT))
 
+# default smoke user
+SMOKEUSER_KEY = "{{cluster-env/smokeuser}}"
+SMOKEUSER_SCRIPT_PARAM_KEY = 'default.smoke.user'
+SMOKEUSER_DEFAULT = 'ambari-qa'
 
 def get_tokens():
   """
   Returns a tuple of tokens in the format {{site/property}} that will be used
   to build the dictionary passed into execute
   """
-  return (TEMPLETON_PORT_KEY, SECURITY_ENABLED_KEY, WEBHCAT_KEYTAB_KEY, WEBHCAT_PRINCIPAL_KEY, KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY)
+  return (TEMPLETON_PORT_KEY, SECURITY_ENABLED_KEY, WEBHCAT_KEYTAB_KEY,
+    WEBHCAT_PRINCIPAL_KEY, KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY, SMOKEUSER_KEY)
   
 
 def execute(configurations={}, parameters={}, host_name=None):
@@ -101,8 +106,16 @@ def execute(configurations={}, parameters={}, host_name=None):
   if host_name is None:
     host_name = socket.getfqdn()
 
+  smokeuser = SMOKEUSER_DEFAULT
+
+  if SMOKEUSER_KEY in configurations:
+    smokeuser = configurations[SMOKEUSER_KEY]
+
+  if SMOKEUSER_SCRIPT_PARAM_KEY in parameters:
+    smokeuser = parameters[SMOKEUSER_SCRIPT_PARAM_KEY]
+
   # webhcat always uses http, never SSL
-  query_url = "http://{0}:{1}/templeton/v1/status".format(host_name, webhcat_port)
+  query_url = "http://{0}:{1}/templeton/v1/status?user.name={2}".format(host_name, webhcat_port, smokeuser)
 
   # initialize
   total_time = 0