浏览代码

Added missing conditions and error logging for Hive HA via ZK (#2828)

Jira: CDPD-10924
Mahesh Balakrishnan 3 年之前
父节点
当前提交
2a4d826607

+ 6 - 2
apps/beeswax/src/beeswax/server/dbms.py

@@ -204,7 +204,8 @@ def get_query_server_config(name='beeswax', connector=None):
           hiveservers = get_zk_hs2()
           LOG.debug("Available Hive Servers: {0}".format(hiveservers))
           if not hiveservers:
-            raise PopupException(_('There is no running Hive server available'))
+            LOG.error('There are no running Hive server available')
+            raise PopupException(_('There are no running Hive server available'))
           server_to_use = 0
           LOG.debug("Selected Hive server {0}: {1}".format(server_to_use, hiveservers[server_to_use]))
           cache.set(
@@ -222,7 +223,7 @@ def get_query_server_config(name='beeswax', connector=None):
         if HIVE_DISCOVERY_HS2.get():
           # Replace ActiveEndpoint if the current HS2 is down
           hiveservers = get_zk_hs2()
-          if hiveservers is not None:
+          if hiveservers:
             server_to_use = 0
             hs2_host_name = hiveservers[server_to_use].split(";")[0].split("=")[1].split(":")[0]
             hs2_in_active_endpoint = hs2_host_name in activeEndpoint
@@ -240,6 +241,9 @@ def get_query_server_config(name='beeswax', connector=None):
                   "port": hiveservers[server_to_use].split(";")[0].split("=")[1].split(":")[1]
                 })
               )
+          else:
+            LOG.error('Currently there are no HiveServer2 running')
+            raise PopupException(_('Currently there are no HiveServer2 running'))
 
       activeEndpoint = json.loads(cache.get("hiveserver2"))
 

+ 2 - 2
apps/beeswax/src/beeswax/server/dbms_tests.py

@@ -141,7 +141,7 @@ class TestGetQueryServerConfig():
               try:
                 query_server = get_query_server_config(name='hive')
               except PopupException as e:
-                assert_equal(e.message, 'There is no running Hive server available')
+                assert_equal(e.message, 'There are no running Hive server available')
 
   def test_get_hs2_discovery(self):
 
@@ -160,7 +160,7 @@ class TestGetQueryServerConfig():
           try:
             query_server = get_query_server_config(name='hive')
           except PopupException as e:
-            assert_equal(e.message, 'There is no running Hive server available')
+            assert_equal(e.message, 'There are no running Hive server available')
 
           assert_equal(query_server['server_name'], 'beeswax')
           assert_equal(query_server['server_host'], 'hive-llap-1.gethue.com')

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -101,7 +101,7 @@ def query_error_handler(func):
       message = force_unicode(str(e))
       if 'timed out' in message:
         raise OperationTimeout(e)
-      elif 'Could not connect to any' in message:
+      elif 'Connection refused' in message or 'Name or service not known' in message or 'Could not connect to any' in message:
         reset_ha()
       else:
         raise QueryError(message)