Browse Source

MAPREDUCE-6091. YARNRunner.getJobStatus() fails with ApplicationNotFoundException if the job rolled off the RM view. Contributed by Sangjin Lee
(cherry picked from commit 951847ba94442b8d928435decfbea9ea20882912)

Jason Lowe 10 năm trước cách đây
mục cha
commit
bdb864e5e1

+ 4 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -139,6 +139,10 @@ Release 2.6.0 - UNRELEASED
     MAPREDUCE-6086. mapreduce.job.credentials.binary should allow all URIs. 
     (Zhihai Xu via kasha)
 
+    MAPREDUCE-6091. YARNRunner.getJobStatus() fails with
+    ApplicationNotFoundException if the job rolled off the RM view (Sangjin
+    Lee via jlowe)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

+ 3 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java

@@ -69,6 +69,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.factories.RecordFactory;
@@ -150,6 +151,8 @@ public class ClientServiceDelegate {
     ApplicationReport application = null;
     try {
       application = rm.getApplicationReport(appId);
+    } catch (ApplicationNotFoundException e) {
+      application = null;
     } catch (YarnException e2) {
       throw new IOException(e2);
     }

+ 5 - 3
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientServiceDelegate.java

@@ -31,8 +31,6 @@ import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Assert;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.JobID;
 import org.apache.hadoop.mapreduce.JobStatus;
@@ -56,8 +54,10 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.util.Records;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -488,7 +488,9 @@ public class TestClientServiceDelegate {
   private ResourceMgrDelegate getRMDelegate() throws IOException {
     ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class);
     try {
-      when(rm.getApplicationReport(jobId.getAppId())).thenReturn(null);
+      ApplicationId appId = jobId.getAppId();
+      when(rm.getApplicationReport(appId)).
+          thenThrow(new ApplicationNotFoundException(appId + " not found"));
     } catch (YarnException e) {
       throw new IOException(e);
     }

+ 2 - 7
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestNonExistentJob.java

@@ -90,13 +90,8 @@ public class TestNonExistentJob extends TestCase {
   }
 
   public void testGetInvalidJob() throws Exception {
-    try {
-      RunningJob runJob = new JobClient(getJobConf()).getJob(JobID.forName("job_0_0"));
-      fail("Exception is expected to thrown ahead!");
-    } catch (Exception e) {
-      assertTrue(e instanceof IOException);
-      assertTrue(e.getMessage().contains("ApplicationNotFoundException"));
-    }
+    RunningJob runJob = new JobClient(getJobConf()).getJob(JobID.forName("job_0_0"));
+    assertNull(runJob);
   }
 
 }