ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-13575. Hive View query error, should use GetOperationStatus thrift api to verify if hive query is completed successfully. (Nitiraj Singh Rathore via yusaku)
Date Thu, 29 Oct 2015 17:47:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 026816d41 -> 0e2d22167


AMBARI-13575. Hive View query error, should use GetOperationStatus thrift api to verify if
hive query is completed successfully. (Nitiraj Singh Rathore via yusaku)


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

Branch: refs/heads/trunk
Commit: 0e2d221675ff6a7a0670eda4051bd3a660bfb9dc
Parents: 026816d
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Thu Oct 29 10:47:03 2015 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Thu Oct 29 10:47:03 2015 -0700

----------------------------------------------------------------------
 .../view/hive/resources/jobs/JobService.java    |  8 +++++
 .../resources/jobs/viewJobs/JobController.java  |  6 ++++
 .../jobs/viewJobs/JobControllerImpl.java        |  6 ++++
 .../controllers/index/history-query/results.js  | 31 +++++++++++++++++++-
 4 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0e2d2216/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/JobService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/JobService.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/JobService.java
index a2c5f5e..fd69893 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/JobService.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/JobService.java
@@ -273,6 +273,14 @@ public class JobService extends BaseService {
                              @QueryParam("columns") final String requestedColumns) {
     try {
       final JobController jobController = getResourceManager().readController(jobId);
+      LOG.info("jobController.getStatus().status : " + jobController.getStatus().status +
" for job : " + jobController.getJob().getId());
+      if(jobController.getStatus().status.equals(Job.JOB_STATE_INITIALIZED)
+         || jobController.getStatus().status.equals(Job.JOB_STATE_PENDING)
+         || jobController.getStatus().status.equals(Job.JOB_STATE_RUNNING)
+         || jobController.getStatus().status.equals(Job.JOB_STATE_UNKNOWN)){
+
+         return Response.status(Response.Status.SERVICE_UNAVAILABLE).header("Retry-After","1").build();
+      }
       if (!jobController.hasResults()) {
         return ResultsPaginationController.emptyResponse().build();
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e2d2216/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobController.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobController.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobController.java
index a25f7d4..3922839 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobController.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobController.java
@@ -19,9 +19,15 @@
 package org.apache.ambari.view.hive.resources.jobs.viewJobs;
 
 import org.apache.ambari.view.hive.client.Cursor;
+import org.apache.ambari.view.hive.client.HiveClientException;
 import org.apache.ambari.view.hive.persistence.utils.ItemNotFound;
+import org.apache.ambari.view.hive.resources.jobs.NoOperationStatusSetException;
+import org.apache.ambari.view.hive.resources.jobs.OperationHandleController;
 
 public interface JobController {
+
+  OperationHandleController.OperationStatus getStatus() throws ItemNotFound, HiveClientException,
NoOperationStatusSetException;
+
   void submit();
 
   void cancel() throws ItemNotFound;

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e2d2216/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobControllerImpl.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobControllerImpl.java
index 3739523..f6d6ed6 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobControllerImpl.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/viewJobs/JobControllerImpl.java
@@ -96,6 +96,12 @@ public class JobControllerImpl implements JobController, ModifyNotificationDeleg
   }
 
   @Override
+  public OperationHandleController.OperationStatus getStatus() throws ItemNotFound, HiveClientException,
NoOperationStatusSetException {
+    OperationHandleController handle = opHandleControllerFactory.getHandleForJob(job);
+    return handle.getOperationStatus();
+  }
+
+  @Override
   public void submit() {
     setupHiveBeforeQueryExecute();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e2d2216/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index/history-query/results.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index/history-query/results.js
b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index/history-query/results.js
index 5c7ded2..9e94b17 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index/history-query/results.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index/history-query/results.js
@@ -142,6 +142,33 @@ export default Ember.ObjectController.extend({
     return defer.promise;
   },
 
+  getResult : function(url){
+    var promise = new Ember.RSVP.Promise(function(resolve,reject){
+      var getData =  function(){
+        //console.log("getData called.");
+        Ember.$.getJSON(url).done(function(data){
+          console.log('results.js : getResult : got success data');
+          resolve(data);
+        }).fail(function(err){
+          if(err.status == 503 && err.getResponseHeader('Retry-After')){
+            var time = Number(err.getResponseHeader('Retry-After'));
+            console.log("results.js : getResult : got error : " + err.status + " with retry.");
+            Ember.run.later(this,
+            function(){
+              getData();
+            },time*1000);
+          }else{
+            console.log("results.js : getResult : rejected. ");
+            reject(err);
+          }
+        });
+      };
+      getData();
+    });
+
+    return promise;
+  },
+
   actions: {
     getNextPage: function (firstPage, job) {
       var self = this;
@@ -164,7 +191,9 @@ export default Ember.ObjectController.extend({
         }
       }
 
-      Ember.$.getJSON(url).then(function (results) {
+      this.getResult(url)
+      .then(function (results) {
+        //console.log("inside then : ", results);
         if (existingJob) {
           existingJob.results.pushObject(results);
           existingJob.set('offset', results.offset);


Mime
View raw message