diff --git hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf index 774d793..43d18df 100644 --- hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf +++ hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf @@ -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' => [ diff --git shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java index 2bc3ca4..fa8bbc1 100644 --- shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java +++ shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java @@ -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.security.PrivilegedExceptionAction; public class WebHCatJTShim23 implements WebHCatJTShim { + private static final Log LOG = LogFactory.getLog(WebHCatJTShim23.class); private JobClient jc; /** @@ -58,11 +61,13 @@ public JobClient run() throws IOException { */ 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; } /** @@ -72,9 +77,11 @@ public JobProfile getJobProfile(JobID jobid) */ 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(); } @@ -83,7 +90,10 @@ public JobStatus getJobStatus(JobID jobid) */ public void killJob(JobID jobid) throws IOException { - RunningJob rj = jc.getJob(jobid); + RunningJob rj = getJob(jobid); + if(rj == null) { + return; + } rj.killJob(); } @@ -108,4 +118,20 @@ public void close() { 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; + } + } }