浏览代码

HUE-6857 [dataeng] Retrieve batch Hive queries via troubleshooting API

Romain Rigaux 8 年之前
父节点
当前提交
ef1d219c23

+ 8 - 1
desktop/libs/metadata/src/metadata/workload_analytics_client.py

@@ -49,9 +49,11 @@ class WorkfloadAnalyticsClient():
     self.user = user
 
   def get_operation_execution_details(self, operation_id):
-
     return WorkloadAnalytics(self.user).get_operation_execution_details(operation_id=operation_id, include_tree=True)
 
+  def get_mr_task_attempt_log(self, operation_execution_id, attempt_id):
+    return WorkloadAnalytics(self.user).get_mr_task_attempt_log(operation_execution_id=operation_execution_id, attempt_id=attempt_id)
+
 
 class WorkloadAnalytics():
 
@@ -64,3 +66,8 @@ class WorkloadAnalytics():
       args.append('--include-tree')
 
     return _exec(args)
+
+  def get_mr_task_attempt_log(self, operation_execution_id, attempt_id):
+    args = ['get-mr-task-attempt-log', '--operation-execution-id', operation_execution_id, '--attempt-id', attempt_id]
+
+    return _exec(args)

+ 8 - 2
desktop/libs/notebook/src/notebook/connectors/dataeng.py

@@ -17,6 +17,7 @@
 
 import logging
 import json
+import re
 import subprocess
 
 from datetime import datetime,  timedelta
@@ -25,6 +26,7 @@ from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext as _
 
 from desktop.lib.exceptions_renderable import PopupException
+from metadata.workload_analytics_client import WorkfloadAnalyticsClient
 
 from notebook.connectors.base import Api, QueryError
 
@@ -40,7 +42,6 @@ def _exec(args):
        ] +
        args
     )
-    print args
   except Exception, e:
     raise PopupException(e, title=_('Error accessing'))
 
@@ -114,7 +115,12 @@ class DataEngApi(Api):
 
 
   def get_log(self, notebook, snippet, startFrom=0, size=None):
-    return ''
+    logs = WorkfloadAnalyticsClient(self.user).get_mr_task_attempt_log(
+        operation_execution_id='cedb71ae-0956-42e1-8578-87b9261d4a37',
+        attempt_id='attempt_1499705340501_0045_m_000000_0'
+    )
+
+    return ''.join(re.findall('(?<=>>> Invoking Beeline command line now >>>)(.*?)(?=<<< Invocation of Beeline command completed <<<)', logs['stdout'], re.DOTALL))
 
 
   def progress(self, snippet, logs):