浏览代码

HADOOP-1326. Change JobClient#runJob() to return the job. Contributed by Owen.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@535981 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父节点
当前提交
dd5520ede4
共有 3 个文件被更改,包括 8 次插入9 次删除
  1. 3 0
      CHANGES.txt
  2. 2 2
      src/java/org/apache/hadoop/mapred/JobClient.java
  3. 3 7
      src/test/org/apache/hadoop/mapred/TestMapRed.java

+ 3 - 0
CHANGES.txt

@@ -342,6 +342,9 @@ Trunk (unreleased changes)
 101. HADOOP-1276.  Make tasktracker expiry interval configurable.
     (Arun C Murthy via cutting)
 
+102. HADOOP-1326.  Change JobClient#RunJob() to return the job.
+    (omalley via cutting)
+
 
 Release 0.12.3 - 2007-04-06
 

+ 2 - 2
src/java/org/apache/hadoop/mapred/JobClient.java

@@ -524,7 +524,7 @@ public class JobClient extends ToolBase implements MRConstants  {
     
   /** Utility that submits a job, then polls for progress until the job is
    * complete. */
-  public static void runJob(JobConf job) throws IOException {
+  public static RunningJob runJob(JobConf job) throws IOException {
     JobClient jc = new JobClient(job);
     boolean error = true;
     RunningJob running = null;
@@ -612,7 +612,7 @@ public class JobClient extends ToolBase implements MRConstants  {
       }
       jc.close();
     }
-      
+    return running;
   }
 
   private static void displayTaskLogs(String taskId, String baseUrl)

+ 3 - 7
src/test/org/apache/hadoop/mapred/TestMapRed.java

@@ -215,14 +215,8 @@ public class TestMapRed extends TestCase {
   }
 
   private static class MyMap implements Mapper {
-    private JobConf conf;
-    private boolean compress;
-    private String taskId;
       
     public void configure(JobConf conf) {
-      this.conf = conf;
-      compress = conf.getBoolean("mapred.compress.map.output", false);
-      taskId = conf.get("mapred.task.id");
     }
       
     public void map(WritableComparable key, Writable value,
@@ -307,7 +301,9 @@ public class TestMapRed extends TestCase {
       f.writeBytes("Hadoop is fun\n");
       f.writeBytes("Is this done, yet?\n");
       f.close();
-      JobClient.runJob(conf);
+      RunningJob rj = JobClient.runJob(conf);
+      assertTrue("job was complete", rj.isComplete());
+      assertTrue("job was successful", rj.isSuccessful());
       Path output = new Path(outDir,
                              ReduceTask.getOutputName(0));
       assertTrue("reduce output exists " + output, fs.exists(output));