Explorar el Código

Merge -r 723459:723460 from main to move the change log of HADOOP-4746 to branch 0.19

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@723463 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang hace 16 años
padre
commit
4338effbbc

+ 2 - 0
CHANGES.txt

@@ -1054,6 +1054,8 @@ Release 0.18.3 - Unreleased
     HADOOP-4679. Datanode prints tons of log messages: waiting for threadgroup
     to exit, active threads is XX. (hairong)
 
+    HADOOP-4746. Job output directory should be normalized. (hairong)
+
 Release 0.18.2 - 2008-11-03
 
   BUG FIXES

+ 10 - 3
src/mapred/org/apache/hadoop/mapred/FileOutputFormat.java

@@ -101,9 +101,16 @@ public abstract class FileOutputFormat<K, V> implements OutputFormat<K, V> {
     if (outDir == null && job.getNumReduceTasks() != 0) {
       throw new InvalidJobConfException("Output directory not set in JobConf.");
     }
-    if (outDir != null && outDir.getFileSystem(job).exists(outDir)) {
-      throw new FileAlreadyExistsException("Output directory " + outDir + 
-                                           " already exists");
+    if (outDir != null) {
+      FileSystem fs = outDir.getFileSystem(job);
+      // normalize the output directory
+      outDir = fs.makeQualified(outDir);
+      setOutputPath(job, outDir);
+      // check its existence
+      if (fs.exists(outDir)) {
+        throw new FileAlreadyExistsException("Output directory " + outDir + 
+                                             " already exists");
+      }
     }
   }
 

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

@@ -748,7 +748,21 @@ public class JobClient extends Configured implements MRConstants, Tool  {
   // job submission directory is world readable/writable/executable
   final static FsPermission JOB_DIR_PERMISSION =
     FsPermission.createImmutable((short) 0777); // rwx-rwx-rwx
-   
+
+  /** Normalize the output path defined in job configuration.
+   * Store the normalized path back into job configuration.
+   * 
+   * @param job job configuration
+   * @throws IOException if any error occurs during normalization
+   */
+  private static void normalizeOutputPath(JobConf job) throws IOException {
+    Path out = FileOutputFormat.getOutputPath(job);
+    if (out!=null) {
+      FileOutputFormat.setOutputPath(job, 
+          out.getFileSystem(job).makeQualified(out));
+    }
+  }
+  
   /**
    * Submit a job to the MR system.
    * This returns a handle to the {@link RunningJob} which can be used to track
@@ -774,7 +788,8 @@ public class JobClient extends Configured implements MRConstants, Tool  {
     configureCommandLineOptions(job, submitJobDir, submitJarFile);
     Path submitJobFile = new Path(submitJobDir, "job.xml");
     
-    // Check the output specification
+    // Normalize and check the output specification
+    normalizeOutputPath(job);
     job.getOutputFormat().checkOutputSpecs(fs, job);
 
     // Create the splits for the job