You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2017/02/24 14:19:45 UTC

[38/50] ambari git commit: AMBARI-20135. Hive view 2.0 : Hanging query - no cancel available.(gauravn7)

AMBARI-20135. Hive view 2.0 : Hanging query - no cancel available.(gauravn7)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6572b16e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6572b16e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6572b16e

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 6572b16e8f721cfabba4b6cdb10d52e6f4f9e382
Parents: 70f23c0
Author: Gaurav Nagar <gr...@gmail.com>
Authored: Thu Feb 23 19:02:13 2017 +0530
Committer: Gaurav Nagar <gr...@gmail.com>
Committed: Thu Feb 23 19:02:13 2017 +0530

----------------------------------------------------------------------
 .../ambari/view/hive20/actor/JdbcConnector.java  |  1 +
 .../resources/ui/app/routes/queries/query.js     | 19 +++++++++++++++++--
 .../src/main/resources/ui/app/services/jobs.js   |  5 +++++
 .../resources/ui/app/templates/queries/query.hbs | 10 +++++++++-
 4 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6572b16e/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/JdbcConnector.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/JdbcConnector.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/JdbcConnector.java
index 1d9744b..61f0b66 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/JdbcConnector.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/JdbcConnector.java
@@ -238,6 +238,7 @@ public class JdbcConnector extends HiveActor {
     try {
       isCancelCalled = true;
       connectionDelegate.cancel();
+      LOG.info("Cancelled JobId:"+ jobId);
     } catch (SQLException e) {
       LOG.error("Failed to cancel job. JobId: {}. {}", message.getJobId(), e);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6572b16e/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
index 5bed2c6..16103b7 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
@@ -137,6 +137,8 @@ export default Ember.Route.extend(UILoggerMixin, {
     controller.set('currentJobId', null);
     controller.set('queryResult', model.get('queryResult'));
     controller.set('isJobSuccess', false);
+    controller.set('isJobCancelled', false);
+    controller.set('isJobCreated', false);
 
     controller.set('isExportResultSuccessMessege', false);
     controller.set('isExportResultFailureMessege', false);
@@ -236,10 +238,10 @@ export default Ember.Route.extend(UILoggerMixin, {
       this.get('controller').set('currentJobId', null);
 
       if(!Ember.isEmpty(isVisualExplainQuery)){
-        var isVisualExplainQuery = true;
+        isVisualExplainQuery = true;
         this.get('controller').set('isVisualExplainQuery', true);
       } else {
-        var isVisualExplainQuery = false;
+        isVisualExplainQuery = false;
         this.get('controller').set('isVisualExplainQuery', false);
       }
 
@@ -285,6 +287,7 @@ export default Ember.Route.extend(UILoggerMixin, {
 
 
       this.get('controller.model').set('isQueryRunning', true);
+      this.get('controller.model').set('isJobCreated',false);
 
       //this.get('controller').set('queryResult', self.get('controller').get('queryResult'));
       //this.get('controller.model').set('queryResult', self.get('controller').get('queryResult'));
@@ -306,10 +309,13 @@ export default Ember.Route.extend(UILoggerMixin, {
         self.get('controller.model').set('queryFile', data.job.queryFile);
         self.get('controller.model').set('logFile', data.job.logFile);
         self.get('controller').set('currentJobId', data.job.id);
+        self.get('controller').set('isJobCreated',true);
 
         self.get('jobs').waitForJobToComplete(data.job.id, 2 * 1000, false)
           .then((status) => {
             self.get('controller').set('isJobSuccess', true);
+            self.get('controller').set('isJobCancelled', false);
+            self.get('controller').set('isJobCreated', false);
             let jobDetails = self.store.peekRecord('job', data.job.id);
             console.log(jobDetails);
             self.send('getJobResult', data, payload.title, jobDetails);
@@ -317,6 +323,9 @@ export default Ember.Route.extend(UILoggerMixin, {
 
           }, (error) => {
             console.log('error', error);
+            self.get('controller').set('isJobSuccess', false);
+            self.get('controller').set('isJobCancelled', false);
+            self.get('controller').set('isJobCreated', false);
             self.get('logger').danger('Failed to execute query.', self.extractError(error));
             self.send('resetDefaultWorksheet');
           });
@@ -328,6 +337,12 @@ export default Ember.Route.extend(UILoggerMixin, {
       });
     },
 
+    stopQuery(){
+      let jobId = this.get('controller').get('currentJobId');
+      this.get('jobs').stopJob(jobId)
+        .then( data => this.get('controller').set('isJobCancelled', true));
+    },
+
     getJobResult(data, payloadTitle, jobDetails){
       let self = this;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6572b16e/contrib/views/hive20/src/main/resources/ui/app/services/jobs.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/jobs.js b/contrib/views/hive20/src/main/resources/ui/app/services/jobs.js
index 8503715..273cd90 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/services/jobs.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/jobs.js
@@ -62,6 +62,11 @@ export default Ember.Service.extend({
     });
   },
 
+  stopJob : function(jobId) {
+    return this.get('store').findRecord('job', jobId)
+      .then(job => job.destroyRecord())
+  },
+
   _fetchDummyResult(jobId) {
     this.get('store').adapterFor('job').fetchResult(jobId);
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/6572b16e/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
index 9be3873..8a771eb 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
@@ -28,7 +28,15 @@
         {{query-editor query=currentQuery updateQuery='updateQuery' }}
       </div>
       <div class="row query-editor-controls">
-        <button class="btn btn-success" {{action "executeQuery" }} disabled={{ worksheet.isQueryRunning}}>{{fa-icon "check"}} Execute</button>
+        {{#if isJobCreated}}
+          {{#if isJobCancelled}}
+             <button class="btn btn-warning" disabled >{{fa-icon "ban"}} Stopping</button>
+          {{else}}
+            <button class="btn btn-warning" {{action "stopQuery" }} >{{fa-icon "ban"}} Stop</button>
+          {{/if}}
+        {{else}}
+          <button class="btn btn-success" {{action "executeQuery" }} disabled={{ worksheet.isQueryRunning}} >{{fa-icon "check"}} Execute</button>
+        {{/if}}
 
         <button class="btn btn-default" {{action "openWorksheetModal" }}>{{fa-icon "save"}} Save As</button>
         <div class="btn-group">