Преглед на файлове

MAPREDUCE-118 Fix Job.getJobID() to get the new ID as soon as it's assigned.
Contributed by Amareshwari Sriramadasu and Dick King


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security@1087539 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas преди 14 години
родител
ревизия
0febd4c6a2

+ 3 - 0
CHANGES.txt

@@ -22,6 +22,9 @@ Release 0.20.204.0 - unreleased
     MAPREDUCE-2409. Distinguish distributed cache artifacts localized as
     files, archives. (Siddharth Seth via cdouglas)
 
+    MAPREDUCE-118 Fix Job.getJobID() to get the new ID as soon as it's 
+    assigned. (Amareshwari Sriramadasu and Dick King via cdouglas)
+
   IMPROVEMENTS
 
     HDFS-1541. Not marking datanodes dead when namenode in safemode.

+ 1 - 0
src/mapred/org/apache/hadoop/mapreduce/Job.java

@@ -463,6 +463,7 @@ public class Job extends JobContext {
     // Connect to the JobTracker and submit the job
     connect();
     info = jobClient.submitJobInternal(conf);
+    super.setJobID(info.getID());
     state = JobState.RUNNING;
    }
   

+ 5 - 1
src/mapred/org/apache/hadoop/mapreduce/JobContext.java

@@ -49,7 +49,7 @@ public class JobContext {
 
   protected final org.apache.hadoop.mapred.JobConf conf;
   protected final Credentials credentials;
-  private final JobID jobId;
+  private JobID jobId;
 
   public static final String JOB_NAMENODES = "mapreduce.job.hdfs-servers";
 
@@ -83,6 +83,10 @@ public class JobContext {
     }
   }
 
+  void setJobID(JobID jobId) {
+    this.jobId = jobId;
+  }
+
   /**
    * Return the configuration for the job.
    * @return the shared configuration object

+ 7 - 0
src/test/org/apache/hadoop/mapreduce/TestMapReduceLocal.java

@@ -137,7 +137,14 @@ public class TestMapReduceLocal extends TestCase {
     job.setInputFormatClass(TrackingTextInputFormat.class);
     FileInputFormat.addInputPath(job, new Path(TEST_ROOT_DIR + "/in"));
     FileOutputFormat.setOutputPath(job, new Path(TEST_ROOT_DIR + "/out"));
+    assertNull("job.getJobID() must be null before the job is submitted",
+	       job.getJobID());
+    job.submit();
+    assertNotNull("job.getJobID() can't be null after the job is submitted",
+		  job.getJobID());
     assertTrue(job.waitForCompletion(false));
+    assertNotNull("job.getJobID() can't be null again after the job is finished",
+		  job.getJobID());
     String out = readFile("out/part-r-00000");
     System.out.println(out);
     assertEquals("a\t1\ncount\t1\nis\t1\nmore\t1\nof\t1\ntest\t4\nthis\t1\nword\t1\n",