Author: dhruba
Date: Mon Oct 25 18:58:45 2010
New Revision: 1027234
URL: http://svn.apache.org/viewvc?rev=1027234&view=rev
Log:
MAPREDUCE-2143. HarFileSystem is able to handle spaces in pathnames.
(Ramkumar Vadali via dhruba)
Modified:
hadoop/mapreduce/trunk/CHANGES.txt
hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/tools/TestHarFileSystem.java
hadoop/mapreduce/trunk/src/tools/org/apache/hadoop/fs/HarFileSystem.java
Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=1027234&r1=1027233&r2=1027234&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Mon Oct 25 18:58:45 2010
@@ -341,6 +341,9 @@ Trunk (unreleased changes)
MAPREDUCE-2126. JobQueueJobInProgressListener's javadoc is inconsistent
with source code. (Jingguo Yao via tomwhite)
+ MAPREDUCE-2143. HarFileSystem is able to handle spaces in pathnames.
+ (Ramkumar Vadali via dhruba)
+
Release 0.21.1 - Unreleased
NEW FEATURES
Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/tools/TestHarFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/tools/TestHarFileSystem.java?rev=1027234&r1=1027233&r2=1027234&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/tools/TestHarFileSystem.java
(original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/tools/TestHarFileSystem.java
Mon Oct 25 18:58:45 2010
@@ -367,4 +367,26 @@ public class TestHarFileSystem extends T
assertTrue("number of bytes left should be -1", reduceIn.read(b) == -1);
reduceIn.close();
}
+
+ public void testSpaces() throws Exception {
+ fs.delete(archivePath, true);
+ Configuration conf = mapred.createJobConf();
+ HadoopArchives har = new HadoopArchives(conf);
+ String[] args = new String[6];
+ args[0] = "-archiveName";
+ args[1] = "foo bar.har";
+ args[2] = "-p";
+ args[3] = fs.getHomeDirectory().toString();
+ args[4] = "test";
+ args[5] = archivePath.toString();
+ int ret = ToolRunner.run(har, args);
+ assertTrue("failed test", ret == 0);
+ Path finalPath = new Path(archivePath, "foo bar.har");
+ Path fsPath = new Path(inputPath.toUri().getPath());
+ Path filePath = new Path(finalPath, "test");
+ // make it a har path
+ Path harPath = new Path("har://" + filePath.toUri().getPath());
+ FileSystem harFs = harPath.getFileSystem(conf);
+ FileStatus[] statuses = harFs.listStatus(finalPath);
+ }
}
Modified: hadoop/mapreduce/trunk/src/tools/org/apache/hadoop/fs/HarFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/tools/org/apache/hadoop/fs/HarFileSystem.java?rev=1027234&r1=1027233&r2=1027234&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/tools/org/apache/hadoop/fs/HarFileSystem.java (original)
+++ hadoop/mapreduce/trunk/src/tools/org/apache/hadoop/fs/HarFileSystem.java Mon Oct 25 18:58:45
2010
@@ -100,7 +100,8 @@ public class HarFileSystem extends Filte
underLyingURI = decodeHarURI(name, conf);
// we got the right har Path- now check if this is
//truly a har filesystem
- Path harPath = archivePath(new Path(name.toString()));
+ Path harPath = archivePath(
+ new Path(name.getScheme(), name.getAuthority(), name.getPath()));
if (harPath == null) {
throw new IOException("Invalid path for the Har Filesystem. " +
name.toString());
@@ -302,16 +303,19 @@ public class HarFileSystem extends Filte
// string manipulation is not good - so
// just use the path api to do it.
private Path makeRelative(String initial, Path p) {
+ String scheme = this.uri.getScheme();
+ String authority = this.uri.getAuthority();
Path root = new Path(Path.SEPARATOR);
if (root.compareTo(p) == 0)
- return new Path(initial);
+ return new Path(scheme, authority, initial);
Path retPath = new Path(p.getName());
Path parent = p.getParent();
for (int i=0; i < p.depth()-1; i++) {
retPath = new Path(parent.getName(), retPath);
parent = parent.getParent();
}
- return new Path(initial, retPath.toString());
+ return new Path(new Path(scheme, authority, initial),
+ retPath.toString());
}
/* this makes a path qualified in the har filesystem
@@ -537,7 +541,7 @@ public class HarFileSystem extends Filte
underlying.getPermission(),
underlying.getOwner(),
underlying.getGroup(),
- makeRelative(this.uri.toString(), new Path(h.name)));
+ makeRelative(this.uri.getPath(), new Path(h.name)));
}
// a single line parser for hadoop archives status
|