Pārlūkot izejas kodu

HUE-1167 [impala] Decoupled backend interface from Beeswax

Beeswax and Impala can choose the interface (Beeswax or HS2) they want.
Romain Rigaux 12 gadi atpakaļ
vecāks
revīzija
c3b8d31

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

@@ -24,9 +24,7 @@ from desktop.lib.conf import Config, coerce_bool
 SERVER_INTERFACE = Config(
   key="server_interface",
   help=_("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."),
-  default="beeswax",
-  private=True)
-
+  default="beeswax")
 
 BEESWAX_SERVER_HOST = Config(
   key="beeswax_server_host",
@@ -42,7 +40,6 @@ BEESWAX_SERVER_PORT = Config(
   default=8002,
   type=int)
 
-
 BEESWAX_META_SERVER_HOST = Config(
   key="beeswax_meta_server_host",
   help=_("Host where internal metastore Thrift daemon is running."),

+ 10 - 3
apps/beeswax/src/beeswax/models.py

@@ -101,9 +101,16 @@ class QueryHistory(models.Model):
 
   def get_query_server_config(self):
     from beeswax.server.dbms import get_query_server_config
-    principal = get_query_server_config(self.server_type)['principal']
-    return dict(zip(['server_name', 'server_host', 'server_port', 'server_type', 'principal'],
-                    [self.server_name, self.server_host, self.server_port, self.server_type, principal]))
+
+    query_server = get_query_server_config(self.server_type)
+    query_server.update({
+        'server_name': self.server_name,
+        'server_host': self.server_host,
+        'server_port': self.server_port,
+        'server_type': self.server_type,
+    })
+
+    return query_server
 
 
   def get_current_statement(self):

+ 9 - 9
apps/beeswax/src/beeswax/server/dbms.py

@@ -42,33 +42,33 @@ def get(user, query_server=None):
   from beeswax.server.beeswax_lib import BeeswaxClient
 
   if query_server is None:
-    query_server = get_query_server_config(requires_ddl=True)
+    query_server = get_query_server_config()
 
-  if SERVER_INTERFACE.get() == HIVE_SERVER2:
+  if query_server['server_interface'] == HIVE_SERVER2:
     return Dbms(HiveServerClientCompatible(HiveServerClient(query_server, user)), QueryHistory.SERVER_TYPE[1][0])
   else:
     return Dbms(BeeswaxClient(query_server, user), QueryHistory.SERVER_TYPE[0][0])
 
 
 
-def get_query_server_config(name='beeswax', requires_ddl=False):
-  if name == 'impala' and not requires_ddl:
-    from impala.conf import SERVER_HOST, SERVER_PORT, IMPALA_PRINCIPAL
+def get_query_server_config(name='beeswax'):
+  if name == 'impala':
+    from impala.conf import SERVER_HOST, SERVER_PORT, IMPALA_PRINCIPAL, SERVER_INTERFACE as IMPALA_SERVER_INTERFACE
     query_server = {
         'server_name': 'impala',
         'server_host': SERVER_HOST.get(),
         'server_port': SERVER_PORT.get(),
-        'support_ddl': False,
-        'principal': IMPALA_PRINCIPAL.get()
+        'server_interface': IMPALA_SERVER_INTERFACE.get(),
+        'principal': IMPALA_PRINCIPAL.get(),
     }
   else:
     query_server = {
         'server_name': 'beeswax',
         'server_host': BEESWAX_SERVER_HOST.get(),
         'server_port': BEESWAX_SERVER_PORT.get(),
-        'support_ddl': True,
+        'server_interface': SERVER_INTERFACE.get(),
         'principal': KERBEROS.HUE_PRINCIPAL.get()
-      }
+    }
 
   return query_server
 

+ 1 - 1
apps/beeswax/src/beeswax/test_base.py

@@ -131,7 +131,7 @@ def get_shared_beeswax_server():
       sleep = 0.001
       make_logged_in_client()
       user = User.objects.get(username='test')
-      query_server = get_query_server_config(requires_ddl=True)
+      query_server = get_query_server_config()
       db = dbms.get(user, query_server)
 
       while not started and time.time() - start < 20.0:

+ 1 - 1
apps/beeswax/src/beeswax/views.py

@@ -376,7 +376,7 @@ def execute_query(request, design_id=None):
   design = safe_get_design(request, query_type, design_id)
   on_success_url = request.REQUEST.get('on_success_url')
 
-  query_server = get_query_server_config(app_name, requires_ddl=False)
+  query_server = get_query_server_config(app_name)
   db = dbms.get(request.user, query_server)
   dbs = db.get_databases()
   databases = ((db, db) for db in dbs)

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

@@ -33,6 +33,12 @@ SERVER_PORT = Config(
   default=21000,
   type=int)
 
+SERVER_INTERFACE = Config(
+  key="server_interface",
+  help=_("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."
+         "'beeswax' requires Beeswax to run for proxying the metadata requests"),
+  default="beeswax")
+
 IMPALA_PRINCIPAL=Config(
   key='impala_principal',
   help=_("Kerberos principal name for Impala. Typically 'impala/hostname.foo.com'."),

+ 12 - 8
desktop/conf.dist/hue.ini

@@ -423,17 +423,21 @@
 ###########################################################################
 
 [impala]
+  # Host of the Impala Server
+  ## server_host=localhost
 
-   # Host of the Impala Server
-   ## server_host=localhost
+  # Port of the Impala Server when using Beeswax Thrift interface
+  ## server_port=21000
+  # Port of the Impala Server when using  Hive Server 2 Thrift interface
+  ## server_port=21050
 
-   # Port of the Impala Server when using Beeswax Thrift interface
-   ## server_port=21000
-   # Port of the Impala Server when using  Hive Server 2 Thrift interface
-   ## server_port=21050
+  # The backend to contact for queries/metadata requests
+  # Choices are 'beeswax' (default), 'hiveserver2'.
+  # 'beeswax' requires Beeswax to run for proxying the metadata requests
+  ## server_interface=beeswax
 
-   # Kerberos principal
-   ## impala_principal=impala/hostname.foo.com
+  # Kerberos principal
+  ## impala_principal=impala/hostname.foo.com
 
 
 ###########################################################################

+ 12 - 8
desktop/conf/pseudo-distributed.ini.tmpl

@@ -426,17 +426,21 @@
 ###########################################################################
 
 [impala]
+  # Host of the Impala Server
+  ## server_host=localhost
 
-   # Host of the Impala Server
-   ## server_host=localhost
+  # Port of the Impala Server when using Beeswax Thrift interface
+  ## server_port=21000
+  # Port of the Impala Server when using  Hive Server 2 Thrift interface
+  ## server_port=21050
 
-   # Port of the Impala Server when using Beeswax Thrift interface
-   ## server_port=21000
-   # Port of the Impala Server when using  Hive Server 2 Thrift interface
-   ## server_port=21050
+  # The backend to contact for queries/metadata requests
+  # Choices are 'beeswax' (default), 'hiveserver2'.
+  # 'beeswax' requires Beeswax to run for proxying the metadata requests
+  ## server_interface=beeswax
 
-   # Kerberos principal
-   ## impala_principal=impala/hostname.foo.com
+  # Kerberos principal
+  ## impala_principal=impala/hostname.foo.com
 
 
 ###########################################################################