Browse Source

Merge -r 755425:755426 to move the change of HADOOP-5259 from main to branch 0.20.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@755428 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 16 years ago
parent
commit
6b0cd0cb63

+ 3 - 0
CHANGES.txt

@@ -797,6 +797,9 @@ Release 0.19.2 - Unreleased
     HADOOP-5479. NameNode should not send empty block replication request to
     DataNode. (hairong)
 
+    HADOOP-5259. Job with output hdfs:/user/<username>/outputpath (no 
+    authority) fails with Wrong FS. (Doug Cutting via hairong)
+
 Release 0.19.1 - 2009-02-23 
 
   IMPROVEMENTS

+ 9 - 1
src/core/org/apache/hadoop/fs/FileSystem.java

@@ -281,7 +281,15 @@ public abstract class FileSystem extends Configured implements Closeable {
 
       if (thatAuthority == null &&                // path's authority is null
           thisAuthority != null) {                // fs has an authority
-        URI defaultUri = getDefaultUri(getConf()); // & is the default fs
+        URI defaultUri = getDefaultUri(getConf()); // & is the conf default 
+        if (thisScheme.equalsIgnoreCase(defaultUri.getScheme()) &&
+            thisAuthority.equalsIgnoreCase(defaultUri.getAuthority()))
+          return;
+        try {                                     // or the default fs's uri
+          defaultUri = get(getConf()).getUri();
+        } catch (IOException e) {
+          throw new RuntimeException(e);
+        }
         if (thisScheme.equalsIgnoreCase(defaultUri.getScheme()) &&
             thisAuthority.equalsIgnoreCase(defaultUri.getAuthority()))
           return;

+ 5 - 0
src/test/org/apache/hadoop/mapred/TestMiniMRWithDFS.java

@@ -277,6 +277,11 @@ public class TestMiniMRWithDFS extends TestCase {
       result = launchWordCount(jobConf, inDir, outDir, input, 3, 1);
       assertEquals("The\t1\nbrown\t1\nfox\t2\nhas\t1\nmany\t1\n" +
                    "quick\t1\nred\t1\nsilly\t1\nsox\t1\n", result.output);
+      final Path outDir2 = new Path("hdfs:/test/wc/output2");
+      jobConf.set("fs.default.name", "hdfs://localhost:" + NameNode.DEFAULT_PORT);
+      result = launchWordCount(jobConf, inDir, outDir2, input, 3, 1);
+      assertEquals("The\t1\nbrown\t1\nfox\t2\nhas\t1\nmany\t1\n" +
+                   "quick\t1\nred\t1\nsilly\t1\nsox\t1\n", result.output);
     } catch (java.net.BindException be) {
       LOG.info("Skip the test this time because can not start namenode on port "
           + NameNode.DEFAULT_PORT, be);