hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From varunsax...@apache.org
Subject hadoop git commit: MAPREDUCE-6762. ControlledJob#toString failed with NPE when job status is not successfully updated (Weiwei Yang via Varun Saxena)
Date Sun, 21 Aug 2016 16:17:10 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 0faee62a0 -> d37b45d61


MAPREDUCE-6762. ControlledJob#toString failed with NPE when job status is not successfully
updated (Weiwei Yang via Varun Saxena)


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

Branch: refs/heads/trunk
Commit: d37b45d613b768950d1cbe342961cd71776816ae
Parents: 0faee62
Author: Varun Saxena <varunsaxena@apache.org>
Authored: Sun Aug 21 21:46:17 2016 +0530
Committer: Varun Saxena <varunsaxena@apache.org>
Committed: Sun Aug 21 21:46:17 2016 +0530

----------------------------------------------------------------------
 .../java/org/apache/hadoop/mapreduce/Job.java   |  2 +-
 .../org/apache/hadoop/mapreduce/TestJob.java    | 36 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/d37b45d6/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java
index 33e820b..45c065d 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java
@@ -422,7 +422,7 @@ public class Job extends JobContextImpl implements JobContext {
    * The user-specified job name.
    */
   public String getJobName() {
-    if (state == JobState.DEFINE) {
+    if (state == JobState.DEFINE || status == null) {
       return super.getJobName();
     }
     ensureState(JobState.RUNNING);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/d37b45d6/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJob.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJob.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJob.java
index 71bacf7..60f390f 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJob.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestJob.java
@@ -26,6 +26,7 @@ import java.io.IOException;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapreduce.JobStatus.State;
+import org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob;
 import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -55,6 +56,41 @@ public class TestJob {
   }
 
   @Test
+  public void testUnexpectedJobStatus() throws Exception {
+    Cluster cluster = mock(Cluster.class);
+    JobID jobid = new JobID("1014873536921", 6);
+    ClientProtocol clientProtocol = mock(ClientProtocol.class);
+    when(cluster.getClient()).thenReturn(clientProtocol);
+    JobStatus status = new JobStatus(jobid, 0f, 0f, 0f, 0f,
+        State.RUNNING, JobPriority.DEFAULT, "root",
+        "testUnexpectedJobStatus", "job file", "tracking URL");
+    when(clientProtocol.getJobStatus(jobid)).thenReturn(status);
+    Job job = Job.getInstance(cluster, status, new JobConf());
+
+    // ensurer job status is RUNNING
+    Assert.assertNotNull(job.getStatus());
+    Assert.assertTrue(job.getStatus().getState() == State.RUNNING);
+
+    // when updating job status, job client could not retrieve
+    // job status, and status reset to null
+    when(clientProtocol.getJobStatus(jobid)).thenReturn(null);
+
+    try {
+      job.updateStatus();
+    } catch (IOException e) {
+      Assert.assertTrue(e != null
+          && e.getMessage().contains("Job status not available"));
+    }
+
+    try {
+      ControlledJob cj = new ControlledJob(job, null);
+      Assert.assertNotNull(cj.toString());
+    } catch (NullPointerException e) {
+      Assert.fail("job API fails with NPE");
+    }
+  }
+
+  @Test
   public void testUGICredentialsPropogation() throws Exception {
     Credentials creds = new Credentials();
     Token<?> token = mock(Token.class);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message