瀏覽代碼

HUE-8631 [hbase] pull thrift transport from hbase-site.xml

Chris Conner 7 年之前
父節點
當前提交
f1e1be242a

+ 2 - 2
apps/hbase/src/hbase/api.py

@@ -27,7 +27,7 @@ from desktop.lib import thrift_util
 from desktop.lib.exceptions_renderable import PopupException
 
 from hbase import conf
-from hbase.hbase_site import get_server_principal, get_server_authentication, is_using_thrift_ssl, is_using_thrift_http
+from hbase.hbase_site import get_server_principal, get_server_authentication, is_using_thrift_ssl, is_using_thrift_http, get_thrift_transport
 from hbase.server.hbase_lib import get_thrift_type, get_client_type
 
 
@@ -99,7 +99,7 @@ class HbaseApi(object):
         kerberos_principal=_security['kerberos_principal_short_name'],
         use_sasl=_security['use_sasl'],
         timeout_seconds=30,
-        transport=conf.THRIFT_TRANSPORT.get(),
+        transport=get_thrift_transport(),
         transport_mode='http' if is_using_thrift_http() else 'socket',
         http_url=('https://' if is_using_thrift_ssl() else 'http://') + target['host'] + ':' + str(target['port']),
         validate=conf.SSL_CERT_CA_VERIFY.get()

+ 11 - 4
apps/hbase/src/hbase/conf.py

@@ -23,6 +23,7 @@ from django.utils.translation import ugettext_lazy as _t, ugettext as _
 
 from desktop.conf import default_ssl_validate
 from desktop.lib.conf import Config, validate_thrift_transport, coerce_bool
+from hbase.hbase_site import get_thrift_transport
 
 
 LOG = logging.getLogger(__name__)
@@ -45,9 +46,9 @@ TRUNCATE_LIMIT = Config(
 
 THRIFT_TRANSPORT = Config(
   key="thrift_transport",
-  default="framed",
-  help=_t("'framed' is used to chunk up responses, which is useful when used in conjunction with the nonblocking server in Thrift."
-       "'buffered' used to be the default of the HBase Thrift Server."),
+  default="buffered",
+  help=_t("Should come from hbase-site.xml, do not set. 'framed' is used to chunk up responses, used with the nonblocking server in Thrift but is not supported in Hue."
+       "'buffered' used to be the default of the HBase Thrift Server. Default is buffered when not set in hbase-site.xml."),
   type=str
 )
 
@@ -60,7 +61,7 @@ HBASE_CONF_DIR = Config(
 # Hidden, just for making patching of older version of Hue easier. To remove in Hue 4.
 USE_DOAS = Config(
   key='use_doas',
-  help=_t('Force Hue to use Http Thrift mode with doas impersonation, regarless of hbase-site.xml properties.'),
+  help=_t('Should come from hbase-site.xml, do not set. Force Hue to use Http Thrift mode with doas impersonation, regarless of hbase-site.xml properties.'),
   default=False,
   type=coerce_bool
 )
@@ -95,6 +96,12 @@ def config_validator(user):
     LOG.exception(msg)
     res.append((NICE_NAME, _(msg)))
 
+  if get_thrift_transport() == "framed":
+    msg = "Hbase config thrift_transport=framed is not supported"
+    LOG.exception(msg)
+    res.append((NICE_NAME, _(msg)))
+
+
 
   res.extend(validate_thrift_transport(THRIFT_TRANSPORT))
 

+ 19 - 2
apps/hbase/src/hbase/hbase_site.py

@@ -22,8 +22,6 @@ import os.path
 from hadoop import confparse
 from desktop.lib.security_util import get_components
 
-from hbase.conf import HBASE_CONF_DIR, USE_DOAS
-
 
 LOG = logging.getLogger(__name__)
 
@@ -33,6 +31,7 @@ SITE_DICT = None
 
 _CNF_HBASE_THRIFT_KERBEROS_PRINCIPAL = 'hbase.thrift.kerberos.principal'
 _CNF_HBASE_AUTHENTICATION = 'hbase.security.authentication'
+_CNF_HBASE_REGIONSERVER_THRIFT_FRAMED = 'hbase.regionserver.thrift.framed'
 
 _CNF_HBASE_IMPERSONATION_ENABLED = 'hbase.thrift.support.proxyuser'
 _CNF_HBASE_USE_THRIFT_HTTP = 'hbase.regionserver.thrift.http'
@@ -61,10 +60,26 @@ def get_server_principal():
 def get_server_authentication():
   return get_conf().get(_CNF_HBASE_AUTHENTICATION, 'NOSASL').upper()
 
+def get_thrift_transport():
+  use_framed = get_conf().get(_CNF_HBASE_REGIONSERVER_THRIFT_FRAMED)
+  if use_framed is not None:
+    if use_framed.upper() == "TRUE":
+      return "framed"
+    else:
+      return "buffered"
+  else:
+    #Avoid circular import
+    from hbase.conf import THRIFT_TRANSPORT
+    return THRIFT_TRANSPORT.get()
+
 def is_impersonation_enabled():
+  #Avoid circular import
+  from hbase.conf import USE_DOAS
   return get_conf().get(_CNF_HBASE_IMPERSONATION_ENABLED, 'FALSE').upper() == 'TRUE' or USE_DOAS.get()
 
 def is_using_thrift_http():
+  #Avoid circular import
+  from hbase.conf import USE_DOAS
   return get_conf().get(_CNF_HBASE_USE_THRIFT_HTTP, 'FALSE').upper() == 'TRUE' or USE_DOAS.get()
 
 def is_using_thrift_ssl():
@@ -75,6 +90,8 @@ def _parse_site():
   global SITE_DICT
   global SITE_PATH
 
+  #Avoid circular import
+  from hbase.conf import HBASE_CONF_DIR
   SITE_PATH = os.path.join(HBASE_CONF_DIR.get(), 'hbase-site.xml')
   try:
     data = file(SITE_PATH, 'r').read()

+ 3 - 3
desktop/conf.dist/hue.ini

@@ -1334,9 +1334,9 @@
   # Hard limit of rows or columns per row fetched before truncating.
   ## truncate_limit = 500
 
-  # 'framed' is used to chunk up responses, which is useful when used in conjunction with the nonblocking server in Thrift.
-  # 'buffered' used to be the default of the HBase Thrift Server.
-  ## thrift_transport=framed
+  # Should come from hbase-site.xml, do not set. 'framed' is used to chunk up responses, used with the nonblocking server in Thrift but is not supported in Hue.
+  # 'buffered' used to be the default of the HBase Thrift Server. Default is buffered when not set in hbase-site.xml.
+  ## thrift_transport=buffered
 
   # Choose whether Hue should validate certificates received from the server.
   ## ssl_cert_ca_verify=true

+ 3 - 3
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1336,9 +1336,9 @@
   # Hard limit of rows or columns per row fetched before truncating.
   ## truncate_limit = 500
 
-  # 'framed' is used to chunk up responses, which is useful when used in conjunction with the nonblocking server in Thrift.
-  # 'buffered' used to be the default of the HBase Thrift Server.
-  ## thrift_transport=framed
+  # Should come from hbase-site.xml, do not set. 'framed' is used to chunk up responses, used with the nonblocking server in Thrift but is not supported in Hue.
+  # 'buffered' used to be the default of the HBase Thrift Server. Default is buffered when not set in hbase-site.xml.
+  ## thrift_transport=buffered
 
   # Choose whether Hue should validate certificates received from the server.
   ## ssl_cert_ca_verify=true