Selaa lähdekoodia

HUE-8330 [cluster] Execute ADB query

Romain Rigaux 7 vuotta sitten
vanhempi
commit
e733351496

+ 5 - 3
desktop/core/src/desktop/api2.py

@@ -84,7 +84,7 @@ def get_context_namespaces(request, interface):
 
   clusters = get_clusters(request.user).values()
 
-  if interface == 'hive':
+  if interface == 'hive' or interface == 'impala':
     namespaces.extend([{
         'id': cluster['id'],
         'name': cluster['name']
@@ -101,6 +101,8 @@ def get_context_namespaces(request, interface):
       )
       response['dynamicClusters'] = True
 
+      # TODO, if impala, tag namespaces with computes
+
   response[interface] = namespaces
   response['status'] = 0
 
@@ -114,7 +116,7 @@ def get_context_computes(request, interface):
 
   clusters = get_clusters(request.user).values()
 
-  if interface == 'hive' or interface == 'oozie' or interface == 'jobs':
+  if interface == 'hive' or interface == 'impala' or interface == 'oozie' or interface == 'jobs':
     computes.extend([{
         'id': cluster['id'],
         'name': cluster['name'],
@@ -124,7 +126,7 @@ def get_context_computes(request, interface):
       } for cluster in clusters
     ])
 
-  if interface == 'hive' or interface == 'jobs':
+  if interface == 'impala' or interface == 'jobs':
     if [cluster for cluster in clusters if cluster['type'] == 'altus']:
       computes.extend([{
           'id': cluster.get('crn', 'None'),

+ 8 - 0
desktop/core/src/desktop/conf.py

@@ -1597,6 +1597,7 @@ def get_clusters(user):
         'id': CLUSTER_ID.get(),
         'name': CLUSTER_ID.get(),
         'type': 'direct',
+        'interface': 'all',
         'server_host': HIVE_SERVER_HOST.get()
         }
       )
@@ -1609,6 +1610,7 @@ def get_clusters(user):
       'id': i,
       'name': cluster_config[i].NAME.get() or i,
       'type': cluster_config[i].TYPE.get(),
+      'interface': cluster_config[i].INTERFACE.get() or 'hive',
       'server_host': cluster_config[i].SERVER_HOST.get()
     }) for i in cluster_config
   ])
@@ -1634,6 +1636,12 @@ CLUSTERS = UnspecifiedConfigSection(
           default='direct',
           type=str,
       ),
+      INTERFACE=Config(
+          "interface",
+          help=_("Type of cluster interface"),
+          default='hive',
+          type=str,
+      ),
       SERVER_HOST=Config(
           "server_host",
           help=_("The host service to contact."),

+ 15 - 0
desktop/libs/notebook/src/notebook/connectors/altus.py

@@ -69,6 +69,12 @@ class SdxApi():
     """
 
     args = ['list-namespaces']
+    
+    if True:
+      args.append('--endpoint-url')
+      args.append('https://ganeshk-2-api.arcus-dev.cloudera.com')
+      args.append('--profile=dev')
+
     return _exec('sdx', args)['namespaces']
 
 
@@ -184,4 +190,13 @@ class AnalyticDbApi():
     """
 
     args = ['list-clusters']
+    
+    if True:
+      args.append('--endpoint-url')
+      args.append('https://ganeshk-2-api.arcus-dev.cloudera.com')
+      args.append('--profile=dev')
+
     return _exec('analyticdb', args)
+
+  def submit_hue_query(self, cluster_crn, payload):
+    return _exec('analyticdb', ['submit-hue-query', '--cluster-crn', cluster_crn, '--payload', payload])

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 188 - 0
desktop/libs/notebook/src/notebook/connectors/altus_adb.py


+ 5 - 1
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -26,7 +26,6 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_unicode
 
 from notebook.conf import get_ordered_interpreters
-from desktop.models import Cluster
 
 
 LOG = logging.getLogger(__name__)
@@ -281,6 +280,8 @@ def get_api(request, snippet):
 
   # Multi cluster
   cluster = json.loads(request.POST.get('cluster', '""'))
+  if cluster and 'altus' in cluster:
+    interface = 'altus-adb'
   print cluster
 
   if interface == 'hiveserver2':
@@ -300,6 +301,9 @@ def get_api(request, snippet):
   elif interface == 'rdbms':
     from notebook.connectors.rdbms import RdbmsApi
     return RdbmsApi(request.user, interpreter=snippet['type'])
+  elif interface == 'altus-adb':
+    from notebook.connectors.altus_adb import AltusAdbApi
+    return AltusAdbApi(user=request.user, cluster_name=cluster, request=request)
   elif interface == 'dataeng':
     from notebook.connectors.dataeng import DataEngApi
     return DataEngApi(user=request.user, request=request, cluster_name=cluster.get('name'))

+ 4 - 4
desktop/libs/notebook/src/notebook/connectors/dataeng.py

@@ -23,7 +23,7 @@ from django.utils.translation import ugettext as _
 
 from metadata.workload_analytics_client import WorkfloadAnalyticsClient
 
-from notebook.connectors.altus import DataEngApi as DataEngClient
+from notebook.connectors.altus import DataEngApi
 from notebook.connectors.base import Api, QueryError
 
 
@@ -43,7 +43,7 @@ class DataEngApi(Api):
   def execute(self, notebook, snippet):
     statement = snippet['statement']
 
-    handle = DataEngClient(self.user).submit_hive_job(self.cluster_name, statement, params=None, job_xml=None)
+    handle = DataEngApi(self.user).submit_hive_job(self.cluster_name, statement, params=None, job_xml=None)
     job = handle['jobs'][0]
 
     if job['status'] not in RUNNING_STATES:
@@ -61,7 +61,7 @@ class DataEngApi(Api):
 
     job_id = snippet['result']['handle']['id']
 
-    handle = DataEngClient(self.user).list_jobs(job_ids=[job_id])
+    handle = DataEngApi(self.user).list_jobs(job_ids=[job_id])
     job = handle['jobs'][0]
 
     if job['status'] in RUNNING_STATES:
@@ -86,7 +86,7 @@ class DataEngApi(Api):
   def cancel(self, notebook, snippet):
     if snippet['result']['handle'].get('id'):
       job_id = snippet['result']['handle']['id']
-      DataEngClient(self.user).terminate_job(job_id=job_id)
+      DataEngApi(self.user).terminate_job(job_id=job_id)
       response = {'status': 0}
     else:
       response = {'status': -1, 'message': _('Could not cancel because of unsuccessful submition.')}

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä