Browse Source

HUE-8208 [kafka] Skeleton of browser and assist

Romain Rigaux 7 years ago
parent
commit
79ae5e0ca7

+ 10 - 0
desktop/core/src/desktop/models.py

@@ -44,6 +44,7 @@ from settings import HUE_DESKTOP_VERSION
 from aws.conf import is_enabled as is_s3_enabled, has_s3_access
 from aws.conf import is_enabled as is_s3_enabled, has_s3_access
 from azure.conf import is_adls_enabled, has_adls_access
 from azure.conf import is_adls_enabled, has_adls_access
 from dashboard.conf import get_engines, HAS_REPORT_ENABLED
 from dashboard.conf import get_engines, HAS_REPORT_ENABLED
+from metadata.conf import has_kafka
 from notebook.conf import SHOW_NOTEBOOKS, get_ordered_interpreters
 from notebook.conf import SHOW_NOTEBOOKS, get_ordered_interpreters
 
 
 from desktop import appmanager
 from desktop import appmanager
@@ -1792,6 +1793,15 @@ class ClusterConfig():
             'page': '/jobbrowser/'
             'page': '/jobbrowser/'
           })
           })
 
 
+    if has_kafka() and (self.cluster_type not in (DATAENG, ANALYTIC_DB)):
+      interpreters.append({
+        'type': 'kafka',
+        'displayName': _('Streams'),
+        'buttonName': _('Browse'),
+        'tooltip': _('Kafka'),
+        'page': '/kafka/'
+      })
+
     if 'hbase' in self.apps and (self.cluster_type not in (DATAENG, ANALYTIC_DB)):
     if 'hbase' in self.apps and (self.cluster_type not in (DATAENG, ANALYTIC_DB)):
       interpreters.append({
       interpreters.append({
         'type': 'hbase',
         'type': 'hbase',

+ 16 - 0
desktop/core/src/desktop/templates/assist.mako

@@ -1898,6 +1898,22 @@ from desktop.views import _ko
                 });
                 });
               }
               }
 
 
+              if (appConfig['browser'] && appConfig['browser']['interpreter_names'].indexOf('kafka') != -1) {
+                var kafkaPanel = new AssistInnerPanel({
+                  panelData: new AssistDbPanel($.extend({
+                    apiHelper: self.apiHelper,
+                    i18n: i18nCollections,
+                    isSolr: true
+                  }, params.sql)),
+                  apiHelper: self.apiHelper,
+                  name: '${ _("Streams") }',
+                  type: 'solr',
+                  icon: 'fa-sitemap',
+                  minHeight: 75
+                });
+                panels.push(kafkaPanel);
+              }
+
               if (appConfig['browser'] && appConfig['browser']['interpreter_names'].indexOf('hbase') != -1) {
               if (appConfig['browser'] && appConfig['browser']['interpreter_names'].indexOf('hbase') != -1) {
                 panels.push(new AssistInnerPanel({
                 panels.push(new AssistInnerPanel({
                   panelData: new AssistHBasePanel({
                   panelData: new AssistHBasePanel({

+ 4 - 0
desktop/libs/metadata/src/metadata/conf.py

@@ -65,6 +65,10 @@ def has_navigator(user):
       and (user.is_superuser or user.has_hue_permission(action="access", app=DJANGO_APPS[0]))
       and (user.is_superuser or user.has_hue_permission(action="access", app=DJANGO_APPS[0]))
 
 
 
 
+def has_kafka():
+  return bool(KAFKA.API_URL.get())
+
+
 def get_security_default():
 def get_security_default():
   '''Get default security value from Hadoop'''
   '''Get default security value from Hadoop'''
   from hadoop import cluster # Avoid dependencies conflicts
   from hadoop import cluster # Avoid dependencies conflicts

+ 2 - 1
desktop/libs/metadata/src/metadata/kafka_client.py

@@ -60,4 +60,5 @@ class KafkaApi(object):
       response = self._root.get('topics')
       response = self._root.get('topics')
       return json.loads(response)
       return json.loads(response)
     except RestException, e:
     except RestException, e:
-      raise KafkaApiException(e)
+      return ['traffic', 'jiras']
+#       raise KafkaApiException(e)