Browse Source

HUE-5435 [notebook] Allow dbproxy classpath to be configurable (#458)

https://github.com/cloudera/hue/pull/458
z-york 9 years ago
parent
commit
16dede5

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

@@ -741,6 +741,9 @@
   ## Main flag to override the automatic starting of the DBProxy server.
   # enable_dbproxy_server=true
 
+  ## Classpath to be appended to the default DBProxy server classpath.
+  # dbproxy_extra_classpath=
+
 
 ###########################################################################
 # Settings to configure your Hadoop cluster.

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

@@ -745,6 +745,9 @@
   ## Main flag to override the automatic starting of the DBProxy server.
   # enable_dbproxy_server=true
 
+  ## Classpath to be appended to the default DBProxy server classpath.
+  # dbproxy_extra_classpath=
+
 
 ###########################################################################
 # Settings to configure your Hadoop cluster.

+ 7 - 0
desktop/libs/notebook/src/notebook/conf.py

@@ -88,6 +88,13 @@ ENABLE_DBPROXY_SERVER = Config(
   default=True
 )
 
+DBPROXY_EXTRA_CLASSPATH = Config(
+  key="dbproxy_extra_classpath",
+  help=_t("Additional classes to put on the dbproxy classpath when starting. Values separated by ':'"),
+  type=str,
+  default=''
+)
+
 ENABLE_QUERY_BUILDER = Config(
   key="enable_query_builder",
   help=_t("Flag to enable the SQL query builder of the table assist."),

+ 5 - 1
desktop/libs/notebook/src/notebook/management/commands/dbproxy_server.py

@@ -19,6 +19,7 @@ import logging
 import os
 
 from django.core.management.base import NoArgsCommand
+from notebook.conf import DBPROXY_EXTRA_CLASSPATH
 
 
 LOG = logging.getLogger(__name__)
@@ -36,7 +37,10 @@ class Command(NoArgsCommand):
 
     cmd = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "librdbms", "java", "bin", "dbproxy")
 
-    LOG.info("Executing %r (%r) (%r)" % (args, args, env))
+    if DBPROXY_EXTRA_CLASSPATH.get():
+      env['CLASSPATH'] = '%s:%s' % (DBPROXY_EXTRA_CLASSPATH.get(), env.get('CLASSPATH', ''))
+
+    LOG.info("Executing %r (%r) (%r)" % (cmd, args, env))
 
     # Use exec, so that this takes only one process.
     os.execvpe(cmd, args, env)