hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r1309453 - in /hadoop/common/trunk/hadoop-tools/hadoop-archives/src: main/java/org/apache/hadoop/tools/HadoopArchives.java test/java/org/apache/hadoop/tools/TestHadoopArchives.java
Date Wed, 04 Apr 2012 15:28:17 GMT
Author: bobby
Date: Wed Apr  4 15:28:17 2012
New Revision: 1309453

URL: http://svn.apache.org/viewvc?rev=1309453&view=rev
Log:
MAPREDUCE-3082. Archive command take wrong path for input file with current directory (John
George via bobby)

Modified:
    hadoop/common/trunk/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java
    hadoop/common/trunk/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java

Modified: hadoop/common/trunk/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java?rev=1309453&r1=1309452&r2=1309453&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java
(original)
+++ hadoop/common/trunk/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java
Wed Apr  4 15:28:17 2012
@@ -830,11 +830,18 @@ public class HadoopArchives implements T
         throw new IOException("Parent path not specified.");
       }
       parentPath = new Path(args[i+1]);
+      if (!parentPath.isAbsolute()) {
+        parentPath= parentPath.getFileSystem(getConf()).makeQualified(parentPath);
+      }
+
       i+=2;
       //read the rest of the paths
       for (; i < args.length; i++) {
         if (i == (args.length - 1)) {
           destPath = new Path(args[i]);
+          if (!destPath.isAbsolute()) {
+            destPath = destPath.getFileSystem(getConf()).makeQualified(destPath);
+          }
         }
         else {
           Path argPath = new Path(args[i]);

Modified: hadoop/common/trunk/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java?rev=1309453&r1=1309452&r2=1309453&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
(original)
+++ hadoop/common/trunk/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
Wed Apr  4 15:28:17 2012
@@ -103,7 +103,42 @@ public class TestHadoopArchives extends 
     super.tearDown();
   }
   
-  
+   
+  public void testRelativePath() throws Exception {
+    fs.delete(archivePath, true);
+
+    final Path sub1 = new Path(inputPath, "dir1");
+    fs.mkdirs(sub1);
+    createFile(sub1, "a", fs);
+    final Configuration conf = mapred.createJobConf();
+    final FsShell shell = new FsShell(conf);
+
+    final List<String> originalPaths = lsr(shell, "input");
+    System.out.println("originalPath: " + originalPaths);
+    final URI uri = fs.getUri();
+    final String prefix = "har://hdfs-" + uri.getHost() +":" + uri.getPort()
+        + archivePath.toUri().getPath() + Path.SEPARATOR;
+
+    {
+      final String harName = "foo.har";
+      final String[] args = {
+          "-archiveName",
+          harName,
+          "-p",
+          "input",
+          "*",
+          "archive"
+      };
+      System.setProperty(HadoopArchives.TEST_HADOOP_ARCHIVES_JAR_PATH, HADOOP_ARCHIVES_JAR);
+      final HadoopArchives har = new HadoopArchives(mapred.createJobConf());
+      assertEquals(0, ToolRunner.run(har, args));
+
+      //compare results
+      final List<String> harPaths = lsr(shell, prefix + harName);
+      assertEquals(originalPaths, harPaths);
+    }
+  }
+
   public void testPathWithSpaces() throws Exception {
     fs.delete(archivePath, true);
 
@@ -170,8 +205,11 @@ public class TestHadoopArchives extends 
       System.setErr(oldErr);
     }
     System.out.println("lsr results:\n" + results);
+    String dirname = dir;
+    if (dir.lastIndexOf(Path.SEPARATOR) != -1 ) {
+      dirname = dir.substring(dir.lastIndexOf(Path.SEPARATOR));
+    }
 
-    final String dirname = dir.substring(dir.lastIndexOf(Path.SEPARATOR));
     final List<String> paths = new ArrayList<String>();
     for(StringTokenizer t = new StringTokenizer(results, "\n");
         t.hasMoreTokens(); ) {



Mime
View raw message