Browse Source

HUE-1174 [impala] config check for Impala

Romain Rigaux 12 years ago
parent
commit
448a488661

+ 24 - 5
apps/impala/src/impala/conf.py

@@ -17,28 +17,47 @@
 
 import socket
 
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _t, ugettext as _
 from desktop.lib.conf import Config
 
+from impala.settings import NICE_NAME
+
 
 SERVER_HOST = Config(
   key="server_host",
-  help=_("Host of the Impala Server."),
+  help=_t("Host of the Impala Server."),
   default="localhost")
 
 SERVER_PORT = Config(
   key="server_port",
-  help=_("Port of the Impala Server."),
+  help=_t("Port of the Impala Server."),
   default=21050,
   type=int)
 
 SERVER_INTERFACE = Config(
   key="server_interface",
-  help=_("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."),
+  help=_t("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."),
   default="hiveserver2")
 
 IMPALA_PRINCIPAL=Config(
   key='impala_principal',
-  help=_("Kerberos principal name for Impala. Typically 'impala/hostname.foo.com'."),
+  help=_t("Kerberos principal name for Impala. Typically 'impala/hostname.foo.com'."),
   type=str,
   default="impala/%s" % socket.getfqdn())
+
+
+def config_validator(user):
+  # dbms is dependent on beeswax.conf (this file)
+  # import in method to avoid circular dependency
+  from beeswax.server import dbms
+  from beeswax.server.dbms import get_query_server_config
+
+  res = []
+  try:
+    query_server = get_query_server_config(name='impala')
+    server = dbms.get(user, query_server)
+    server.get_databases()
+  except:
+    res.append((NICE_NAME, _("No available Impalad to send queries to.")))
+
+  return res

+ 10 - 7
apps/pig/src/pig/templates/app.mako

@@ -147,16 +147,19 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
             <li data-bind="visible: currentScript().isRunning(), click: showScriptLogs" data-section="logs">
               <a href="#" title="${ _('Show Logs') }" rel="tooltip" data-placement="right">${ _('Current Logs') }</a>
             </li>
+            <li>
+            <br/>
+            <i class="icon-question-sign" id="help"></i>
+            <div id="help-content" class="hide">
+              <ul style="text-align: left;">
+                <li>${ _("Press CTRL + Space to autocomplete") }</li>
+                <li>${ _("You can execute the current script by pressing CTRL + ENTER or CTRL + . in the editor") }</li>
+              </ul>
+            </div>
+            </li>
           </ul>
         </form>
       </div>
-      <i class="icon-question-sign" id="help"></i>
-      <div id="help-content" class="hide">
-        <ul style="text-align: left;">
-          <li>${ _("Press CTRL + Space to autocomplete") }</li>
-          <li>${ _("You can execute the current script by pressing CTRL + ENTER or CTRL + . in the editor") }</li>
-        </ul>
-      </div>
     </div>
 
     <div class="span10">

+ 2 - 2
desktop/core/src/desktop/templates/check_config.mako

@@ -27,7 +27,7 @@ from django.utils.translation import ugettext as _
         <table class="table table-striped">
       % for confvar, error in error_list:
         <tr>
-            <td width="5%">
+            <td width="15%">
                 <code>
                 % if isinstance(confvar, str):
                   ${confvar | n}
@@ -47,6 +47,6 @@ from django.utils.translation import ugettext as _
       % endfor
     </table>
     % else:
-      <h2>${_('All OK. Configuration check passed.')}</h2>
+      <h5>${_('All OK. Configuration check passed.')}</h5>
     % endif
 </div>