Author: cmccabe
Date: Wed Feb 12 02:12:11 2014
New Revision: 1567497
URL: http://svn.apache.org/r1567497
Log:
HADOOP-10338. Cannot get the FileStatus of the root inode from the new Globber
(cmccabe)
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1567497&r1=1567496&r2=1567497&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Wed Feb
12 02:12:11 2014
@@ -334,6 +334,9 @@ Release 2.4.0 - UNRELEASED
HADOOP-10326. M/R jobs can not access S3 if Kerberos is enabled. (bc Wong
via atm)
+ HADOOP-10338. Cannot get the FileStatus of the root inode from the new
+ Globber (cmccabe)
+
Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java?rev=1567497&r1=1567496&r2=1567497&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
Wed Feb 12 02:12:11 2014
@@ -114,7 +114,8 @@ class Globber {
if (fs != null) {
scheme = fs.getUri().getScheme();
} else {
- scheme = fc.getDefaultFileSystem().getUri().getScheme();
+ scheme = fc.getFSofPath(fc.fixRelativePart(path)).
+ getUri().getScheme();
}
}
return scheme;
@@ -126,7 +127,8 @@ class Globber {
if (fs != null) {
authority = fs.getUri().getAuthority();
} else {
- authority = fc.getDefaultFileSystem().getUri().getAuthority();
+ authority = fc.getFSofPath(fc.fixRelativePart(path)).
+ getUri().getAuthority();
}
}
return authority ;
@@ -162,18 +164,26 @@ class Globber {
// Starting out at the root of the filesystem, we try to match
// filesystem entries against pattern components.
ArrayList<FileStatus> candidates = new ArrayList<FileStatus>(1);
+ // To get the "real" FileStatus of root, we'd have to do an expensive
+ // RPC to the NameNode. So we create a placeholder FileStatus which has
+ // the correct path, but defaults for the rest of the information.
+ // Later, if it turns out we actually want the FileStatus of root, we'll
+ // replace the placeholder with a real FileStatus obtained from the
+ // NameNode.
+ FileStatus rootPlaceholder;
if (Path.WINDOWS && !components.isEmpty()
&& Path.isWindowsAbsolutePath(absPattern.toUri().getPath(), true)) {
// On Windows the path could begin with a drive letter, e.g. /E:/foo.
// We will skip matching the drive letter and start from listing the
// root of the filesystem on that drive.
String driveLetter = components.remove(0);
- candidates.add(new FileStatus(0, true, 0, 0, 0, new Path(scheme,
- authority, Path.SEPARATOR + driveLetter + Path.SEPARATOR)));
+ rootPlaceholder = new FileStatus(0, true, 0, 0, 0, new Path(scheme,
+ authority, Path.SEPARATOR + driveLetter + Path.SEPARATOR));
} else {
- candidates.add(new FileStatus(0, true, 0, 0, 0,
- new Path(scheme, authority, Path.SEPARATOR)));
+ rootPlaceholder = new FileStatus(0, true, 0, 0, 0,
+ new Path(scheme, authority, Path.SEPARATOR));
}
+ candidates.add(rootPlaceholder);
for (int componentIdx = 0; componentIdx < components.size();
componentIdx++) {
@@ -245,6 +255,12 @@ class Globber {
candidates = newCandidates;
}
for (FileStatus status : candidates) {
+ // Use object equality to see if this status is the root placeholder.
+ // See the explanation for rootPlaceholder above for more information.
+ if (status == rootPlaceholder) {
+ status = getFileStatus(rootPlaceholder.getPath());
+ if (status == null) continue;
+ }
// HADOOP-3497 semantics: the user-defined filter is applied at the
// end, once the full path is built up.
if (filter.accept(status.getPath())) {