Преглед изворни кода

[impala] Add an idle session configurable timeout

Compatible with Impala 2.5 and defaults to 12hours
https://issues.cloudera.org/browse/IMPALA-2248
Romain Rigaux пре 10 година
родитељ
комит
cfc6d16

+ 3 - 1
apps/beeswax/src/beeswax/server/dbms.py

@@ -72,7 +72,8 @@ def get(user, query_server=None):
 def get_query_server_config(name='beeswax', server=None):
   if name == 'impala':
     from impala.conf import SERVER_HOST as IMPALA_SERVER_HOST, SERVER_PORT as IMPALA_SERVER_PORT, \
-        IMPALA_PRINCIPAL, IMPERSONATION_ENABLED, QUERYCACHE_ROWS, QUERY_TIMEOUT_S, AUTH_USERNAME as IMPALA_AUTH_USERNAME, AUTH_PASSWORD as IMPALA_AUTH_PASSWORD
+        IMPALA_PRINCIPAL, IMPERSONATION_ENABLED, QUERYCACHE_ROWS, QUERY_TIMEOUT_S, AUTH_USERNAME as IMPALA_AUTH_USERNAME, AUTH_PASSWORD as IMPALA_AUTH_PASSWORD, \
+        SESSION_TIMEOUT_S
 
     query_server = {
         'server_name': 'impala',
@@ -82,6 +83,7 @@ def get_query_server_config(name='beeswax', server=None):
         'impersonation_enabled': IMPERSONATION_ENABLED.get(),
         'querycache_rows': QUERYCACHE_ROWS.get(),
         'QUERY_TIMEOUT_S': QUERY_TIMEOUT_S.get(),
+        'SESSION_TIMEOUT_S': SESSION_TIMEOUT_S.get(),
         'auth_username': IMPALA_AUTH_USERNAME.get(),
         'auth_password': IMPALA_AUTH_PASSWORD.get()
     }

+ 3 - 0
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -544,6 +544,9 @@ class HiveServerClient:
     if self.query_server['server_name'] == 'sparksql': # All the time
       kwargs['configuration'].update({'hive.server2.proxy.user': user.username})
 
+    if self.query_server['server_name'] == 'impala' and self.query_server['SESSION_TIMEOUT_S'] > 0:
+      kwargs['configuration'].update({'idle_session_timeout': str(self.query_server['SESSION_TIMEOUT_S'])})
+
     LOG.info('Opening %s thrift session for user %s' % (self.query_server['server_name'], user.username))
 
     req = TOpenSessionReq(**kwargs)

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

@@ -83,6 +83,14 @@ QUERY_TIMEOUT_S = Config(
   default=600
 )
 
+SESSION_TIMEOUT_S = Config(
+  key="session_timeout_s",
+  help=_t("If SESSION_TIMEOUT_S > 0, the session will be timed out (i.e. cancelled) if Impala does not do any work"
+          " (compute or send back results) for that session within QUERY_TIMEOUT_S seconds."),
+  type=int,
+  default=12 * 60 * 60
+)
+
 SSL = ConfigSection(
   key='ssl',
   help=_t('SSL configuration for the server.'),

+ 5 - 1
desktop/conf.dist/hue.ini

@@ -798,10 +798,14 @@
   # This will free all the query resources in Impala, but also make its results inaccessible.
   ## close_queries=true
 
-  # If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
+  # If > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
   # (compute or send back results) for that query within QUERY_TIMEOUT_S seconds.
   ## query_timeout_s=600
 
+  # If > 0, the session will be timed out (i.e. cancelled) if Impala does not do any work
+  # (compute or send back results) for that session within QUERY_TIMEOUT_S seconds (default 12hours).
+  ## session_timeout_s=43200
+
   [[ssl]]
     # SSL communication enabled for this server.
     ## enabled=false

+ 5 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -800,10 +800,14 @@
   # This will free all the query resources in Impala, but also make its results inaccessible.
   ## close_queries=true
 
-  # If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
+  # If > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
   # (compute or send back results) for that query within QUERY_TIMEOUT_S seconds.
   ## query_timeout_s=600
 
+  # If > 0, the session will be timed out (i.e. cancelled) if Impala does not do any work
+  # (compute or send back results) for that session within QUERY_TIMEOUT_S seconds (default 12hours).
+  ## session_timeout_s=43200
+
   [[ssl]]
     # SSL communication enabled for this server.
     ## enabled=false