瀏覽代碼

HADOOP-4746. Job output directory should be normalized. Contributed by Hairong Kuang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@723460 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 16 年之前
父節點
當前提交
255d941b9c
共有 2 個文件被更改,包括 12 次插入3 次删除
  1. 2 0
      CHANGES.txt
  2. 10 3
      src/mapred/org/apache/hadoop/mapred/FileOutputFormat.java

+ 2 - 0
CHANGES.txt

@@ -1321,6 +1321,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");
+      }
     }
   }