浏览代码

HUE-5714 [hive] Close SQL canary query "Select "Hello World""

Impala too.
Romain Rigaux 8 年之前
父节点
当前提交
7065edb
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 8 1
      apps/beeswax/src/beeswax/conf.py
  2. 8 1
      apps/impala/src/impala/conf.py

+ 8 - 1
apps/beeswax/src/beeswax/conf.py

@@ -29,6 +29,7 @@ from desktop.lib.exceptions import StructuredThriftTransportException
 
 from beeswax.settings import NICE_NAME
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -220,6 +221,7 @@ AUTH_PASSWORD_SCRIPT = Config(
 def config_validator(user):
   # dbms is dependent on beeswax.conf (this file)
   # import in method to avoid circular dependency
+  from beeswax.design import hql_query
   from beeswax.server import dbms
 
   res = []
@@ -227,7 +229,12 @@ def config_validator(user):
     try:
       if not 'test' in sys.argv: # Avoid tests hanging
         server = dbms.get(user)
-        server.execute_statement("SELECT 'Hello World!';")
+        query = hql_query("SELECT 'Hello World!';")
+        handle = server.execute_and_wait(query, timeout_sec=10.0)
+
+        if handle:
+          server.fetch(handle, rows=100)
+          server.close(handle)
     except StructuredThriftTransportException, e:
       if 'Error validating the login' in str(e):
         msg = 'Failed to authenticate to HiveServer2, check authentication configurations.'

+ 8 - 1
apps/impala/src/impala/conf.py

@@ -27,6 +27,7 @@ from desktop.lib.exceptions import StructuredThriftTransportException
 
 from impala.settings import NICE_NAME
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -174,6 +175,7 @@ AUTH_PASSWORD_SCRIPT = Config(
 def config_validator(user):
   # dbms is dependent on beeswax.conf (this file)
   # import in method to avoid circular dependency
+  from beeswax.design import hql_query
   from beeswax.server import dbms
   from beeswax.server.dbms import get_query_server_config
 
@@ -183,7 +185,12 @@ def config_validator(user):
       if not 'test' in sys.argv: # Avoid tests hanging
         query_server = get_query_server_config(name='impala')
         server = dbms.get(user, query_server)
-        server.execute_statement("SELECT 'Hello World!';")
+        query = hql_query("SELECT 'Hello World!';")
+        handle = server.execute_and_wait(query, timeout_sec=10.0)
+
+        if handle:
+          server.fetch(handle, rows=100)
+          server.close(handle)
     except StructuredThriftTransportException, ex:
       if 'TSocket read 0 bytes' in str(ex):  # this message appears when authentication fails
         msg = "Failed to authenticate to Impalad, check authentication configurations."