Author: brandonli
Date: Fri Jan 17 23:28:07 2014
New Revision: 1559279
URL: http://svn.apache.org/r1559279
Log:
HADOOP-10112. har file listing doesn't work with wild card. Contributed by
Brandon Li
Modified:
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
Modified:
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1559279&r1=1559278&r2=1559279&view=diff
==============================================================================
---
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/CHANGES.txt
Fri Jan 17 23:28:07 2014
@@ -90,6 +90,8 @@ Release 2.3.0 - UNRELEASED
HADOOP-10234. "hadoop.cmd jar" does not propagate exit code. (cnauroth)
+ HADOOP-10112. har file listing doesn't work with wild card. (brandonli)
+
Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES
Modified:
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java?rev=1559279&r1=1559278&r2=1559279&view=diff
==============================================================================
---
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
(original)
+++
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
Fri Jan 17 23:28:07 2014
@@ -17,6 +17,21 @@
*/
package org.apache.hadoop.fs;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -26,14 +41,6 @@ import org.apache.hadoop.io.Text;
import org.apache.hadoop.util.LineReader;
import org.apache.hadoop.util.Progressable;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLDecoder;
-import java.util.*;
-
/**
* This is an implementation of the Hadoop Archive
* Filesystem. This archive Filesystem has index files
@@ -664,15 +671,20 @@ public class HarFileSystem extends FileS
*/
@Override
public FileStatus getFileStatus(Path f) throws IOException {
- HarStatus hstatus = getFileHarStatus(f);
+ Path p = makeQualified(f);
+ if (p.toUri().getPath().length() < archivePath.toString().length()) {
+ // still in the source file system
+ return fs.getFileStatus(new Path(p.toUri().getPath()));
+ }
+
+ HarStatus hstatus = getFileHarStatus(p);
return toFileStatus(hstatus, null);
}
private HarStatus getFileHarStatus(Path f) throws IOException {
// get the fs DataInputStream for the underlying file
// look up the index.
- Path p = makeQualified(f);
- Path harPath = getPathInHar(p);
+ Path harPath = getPathInHar(f);
if (harPath == null) {
throw new IOException("Invalid file name: " + f + " in " + uri);
}
@@ -789,6 +801,11 @@ public class HarFileSystem extends FileS
// to the client
List<FileStatus> statuses = new ArrayList<FileStatus>();
Path tmpPath = makeQualified(f);
+ if (tmpPath.toUri().getPath().length() < archivePath.toString().length()) {
+ // still in the source file system
+ return fs.listStatus(new Path(tmpPath.toUri().getPath()));
+ }
+
Path harPath = getPathInHar(tmpPath);
HarStatus hstatus = metadata.archive.get(harPath);
if (hstatus == null) {