Author: tucu
Date: Mon Jun 25 22:00:45 2012
New Revision: 1353759

URL: http://svn.apache.org/viewvc?rev=1353759&view=rev
Log:
MAPREDUCE-4355. Add JobStatus getJobStatus(JobID) to JobClient. (kkambatl via 
tucu)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    
hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
    
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobClient.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1353759&r1=1353758&r2=1353759&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Mon Jun 25 22:00:45 2012
@@ -8,6 +8,8 @@ Release 1.2.0 - unreleased
 
     HADOOP-8023. Add unset() method to Configuration (tucu)
 
+    MAPREDUCE-4355. Add JobStatus getJobStatus(JobID) to JobClient. (kkambatl 
via tucu)
+
   IMPROVEMENTS
 
     HDFS-3515. Port HDFS-1457 to branch-1. (eli)

Modified: 
hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java?rev=1353759&r1=1353758&r2=1353759&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
 (original)
+++ 
hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
 Mon Jun 25 22:00:45 2012
@@ -1063,13 +1063,28 @@ public class JobClient extends Configure
     }
     return false;
   }
-    
+
+  /**
+   * Get {@link JobStatus} of a job. Returns null if the id does not correspond
+   * to any known job.
+   * 
+   * @param jobid
+   *          the jobid of the job.
+   * @return the {@link JobStatus} object to retrieve the job stats, null if 
the
+   *         <code>jobid</code> doesn't correspond to any known job.
+   * @throws IOException
+   */
+  public JobStatus getJobStatus(final JobID jobid) throws IOException {
+    return jobSubmitClient.getJobStatus(jobid);
+  }
+
   /**
-   * Get an {@link RunningJob} object to track an ongoing job.  Returns
-   * null if the id does not correspond to any known job.
+   * Get an {@link RunningJob} object to track an ongoing job. Returns null if
+   * the id does not correspond to any known job.
    * 
-   * @param jobid the jobid of the job.
-   * @return the {@link RunningJob} handle to track the job, null if the 
+   * @param jobid
+   *          the jobid of the job.
+   * @return the {@link RunningJob} handle to track the job, null if the
    *         <code>jobid</code> doesn't correspond to any known job.
    * @throws IOException
    */

Modified: 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobClient.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobClient.java?rev=1353759&r1=1353758&r2=1353759&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobClient.java
 (original)
+++ 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobClient.java
 Mon Jun 25 22:00:45 2012
@@ -19,7 +19,6 @@ package org.apache.hadoop.mapred;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -41,6 +40,8 @@ public class TestJobClient extends Clust
   
   private static final Log LOG = LogFactory.getLog(TestJobClient.class);
   
+  private JobConf conf;
+
   private String runJob() throws Exception {
     OutputStream os = getFileSystem().create(new Path(getInputDir(), 
"text.txt"));
     Writer wr = new OutputStreamWriter(os);
@@ -49,7 +50,7 @@ public class TestJobClient extends Clust
     wr.write("hello3\n");
     wr.close();
 
-    JobConf conf = createJobConf();
+    conf = createJobConf();
     conf.setJobName("mr");
     conf.setJobPriority(JobPriority.HIGH);
     
@@ -127,4 +128,15 @@ public class TestJobClient extends Clust
     assertEquals("Exit code", 0, exitCode);
     verifyJobPriority(jobId, "VERY_LOW");
   }
+
+  public void testGetJobStatus() throws Exception {
+    String jobIdString = runJob();
+    JobID jobid = JobID.forName(jobIdString);
+
+    JobClient client = new JobClient(conf);
+    assertEquals("JobClient intialization", conf, client.getConf());
+    JobStatus jobStatus = client.getJobStatus(jobid);
+    assertNotNull("Fetch JobStatus", jobStatus);
+    assertEquals("JobId check", jobid, jobStatus.getJobID());
+  }
 }


Reply via email to