hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1594057 - in /hive/trunk: hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java
Date Mon, 12 May 2014 19:12:31 GMT
Author: thejas
Date: Mon May 12 19:12:30 2014
New Revision: 1594057

URL: http://svn.apache.org/r1594057
Log:
HIVE-7035 : Templeton returns 500 for user errors - when job cannot be found (Eugene Koifman
via Thejas Nair)

Modified:
    hive/trunk/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf
    hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java

Modified: hive/trunk/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf?rev=1594057&r1=1594056&r2=1594057&view=diff
==============================================================================
--- hive/trunk/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf (original)
+++ hive/trunk/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf Mon May 12 19:12:30
2014
@@ -58,6 +58,30 @@ $cfg = 
   },
 ##=============================================================================================================
   {
+   'name' => 'TestJobs',
+   'tests' => 
+   [
+    {
+     'num' => 1,
+     #using non-existent jobid; checks http status code
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/jobs/job_1399496111138_0011?user.name=:UNAME:',
+                                #results
+     'status_code' => 400,
+    },
+    {
+     'num' => 2,
+      #using non-existent jobid; checks http status code
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/jobs/job_1399496111138_0011?user.name=:UNAME:',
+                                #results
+     'status_code' => 400,
+    },
+
+   ]
+  },
+##=============================================================================================================
+  {
    'name' => 'TestMapReduce',
    'tests' => 
    [

Modified: hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java?rev=1594057&r1=1594056&r2=1594057&view=diff
==============================================================================
--- hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java (original)
+++ hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java Mon
May 12 19:12:30 2014
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.mapred;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -27,6 +29,7 @@ import java.net.URI;
 import java.security.PrivilegedExceptionAction;
 
 public class WebHCatJTShim23 implements WebHCatJTShim {
+  private static final Log LOG = LogFactory.getLog(WebHCatJTShim23.class);
   private JobClient jc;
 
   /**
@@ -54,11 +57,13 @@ public class WebHCatJTShim23 implements 
    */
   public JobProfile getJobProfile(JobID jobid)
           throws IOException {
-    RunningJob rj = jc.getJob(jobid);
+    RunningJob rj = getJob(jobid);
+    if(rj == null) {
+      return null;
+    }
     JobStatus jobStatus = rj.getJobStatus();
-    JobProfile jobProfile = new JobProfile(jobStatus.getUsername(), jobStatus.getJobID(),
+    return new JobProfile(jobStatus.getUsername(), jobStatus.getJobID(),
             jobStatus.getJobFile(), jobStatus.getTrackingUrl(), jobStatus.getJobName());
-    return jobProfile;
   }
 
   /**
@@ -68,9 +73,11 @@ public class WebHCatJTShim23 implements 
    */
   public JobStatus getJobStatus(JobID jobid)
           throws IOException {
-    RunningJob rj = jc.getJob(jobid);
-    JobStatus jobStatus = rj.getJobStatus();
-    return jobStatus;
+    RunningJob rj = getJob(jobid);
+    if(rj == null) {
+      return null;
+    }
+    return rj.getJobStatus();
   }
 
 
@@ -79,7 +86,10 @@ public class WebHCatJTShim23 implements 
    */
   public void killJob(JobID jobid)
           throws IOException {
-    RunningJob rj = jc.getJob(jobid);
+    RunningJob rj = getJob(jobid);
+    if(rj == null) {
+      return;
+    }
     rj.killJob();
   }
 
@@ -104,4 +114,20 @@ public class WebHCatJTShim23 implements 
   public void addCacheFile(URI uri, Job job) {
     job.addCacheFile(uri);
   }
+  /**
+   * @return {@code null} if no such application exists
+   */
+  private RunningJob getJob(JobID jobid) throws IOException {
+    try {
+      return jc.getJob(jobid);
+    }
+    catch(IOException ex) {
+      String msg = ex.getMessage();
+      if(msg != null && msg.contains("ApplicationNotFoundException")) {
+        LOG.info("Job(" + jobid + ") not found: " + msg);
+        return null;
+      }
+      throw ex;
+    }
+  }
 }



Mime
View raw message