HADOOP-9865. FileContext#globStatus has a regression with respect to relative path. (Contributed by Chaun Lin)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1514531 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
10ec8a248e
commit
8df7e7deec
|
@ -337,6 +337,9 @@ Release 2.3.0 - UNRELEASED
|
||||||
HADOOP-9875. TestDoAsEffectiveUser can fail on JDK 7. (Aaron T. Myers via
|
HADOOP-9875. TestDoAsEffectiveUser can fail on JDK 7. (Aaron T. Myers via
|
||||||
Colin Patrick McCabe)
|
Colin Patrick McCabe)
|
||||||
|
|
||||||
|
HADOOP-9865. FileContext#globStatus has a regression with respect to
|
||||||
|
relative path. (Chuan Lin via Colin Patrick McCabe)
|
||||||
|
|
||||||
|
|
||||||
Release 2.1.1-beta - UNRELEASED
|
Release 2.1.1-beta - UNRELEASED
|
||||||
|
|
||||||
|
|
|
@ -99,24 +99,24 @@ class Globber {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String schemeFromPath(Path path) throws IOException {
|
private String schemeFromPath(Path path) throws IOException {
|
||||||
String scheme = pathPattern.toUri().getScheme();
|
String scheme = path.toUri().getScheme();
|
||||||
if (scheme == null) {
|
if (scheme == null) {
|
||||||
if (fs != null) {
|
if (fs != null) {
|
||||||
scheme = fs.getUri().getScheme();
|
scheme = fs.getUri().getScheme();
|
||||||
} else {
|
} else {
|
||||||
scheme = fc.getFSofPath(path).getUri().getScheme();
|
scheme = fc.getDefaultFileSystem().getUri().getScheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scheme;
|
return scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String authorityFromPath(Path path) throws IOException {
|
private String authorityFromPath(Path path) throws IOException {
|
||||||
String authority = pathPattern.toUri().getAuthority();
|
String authority = path.toUri().getAuthority();
|
||||||
if (authority == null) {
|
if (authority == null) {
|
||||||
if (fs != null) {
|
if (fs != null) {
|
||||||
authority = fs.getUri().getAuthority();
|
authority = fs.getUri().getAuthority();
|
||||||
} else {
|
} else {
|
||||||
authority = fc.getFSofPath(path).getUri().getAuthority();
|
authority = fc.getDefaultFileSystem().getUri().getAuthority();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return authority ;
|
return authority ;
|
||||||
|
|
|
@ -622,21 +622,7 @@ public class TestGlobPaths {
|
||||||
cleanupDFS();
|
cleanupDFS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void pTestRelativePath() throws IOException {
|
|
||||||
try {
|
|
||||||
String [] files = new String[] {"a", "abc", "abc.p", "bacd"};
|
|
||||||
Path[] matchedPath = prepareTesting("a*", files);
|
|
||||||
assertEquals(matchedPath.length, 3);
|
|
||||||
assertEquals(matchedPath[0], new Path(USER_DIR, path[0]));
|
|
||||||
assertEquals(matchedPath[1], new Path(USER_DIR, path[1]));
|
|
||||||
assertEquals(matchedPath[2], new Path(USER_DIR, path[2]));
|
|
||||||
} finally {
|
|
||||||
cleanupDFS();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test {xx,yy} */
|
/* Test {xx,yy} */
|
||||||
@Test
|
@Test
|
||||||
public void pTestCurlyBracket() throws IOException {
|
public void pTestCurlyBracket() throws IOException {
|
||||||
|
@ -1061,4 +1047,43 @@ public class TestGlobPaths {
|
||||||
public void testGlobFillsInSchemeOnFC() throws Exception {
|
public void testGlobFillsInSchemeOnFC() throws Exception {
|
||||||
testOnFileContext(new TestGlobFillsInScheme());
|
testOnFileContext(new TestGlobFillsInScheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that globStatus works with relative paths.
|
||||||
|
**/
|
||||||
|
private static class TestRelativePath implements FSTestWrapperGlobTest {
|
||||||
|
public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
|
||||||
|
throws Exception {
|
||||||
|
String[] files = new String[] { "a", "abc", "abc.p", "bacd" };
|
||||||
|
|
||||||
|
Path[] path = new Path[files.length];
|
||||||
|
for(int i=0; i < files.length; i++) {
|
||||||
|
path[i] = wrap.makeQualified(new Path(files[i]));
|
||||||
|
wrap.mkdir(path[i], FsPermission.getDirDefault(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Path patternPath = new Path("a*");
|
||||||
|
Path[] globResults = FileUtil.stat2Paths(wrap.globStatus(patternPath,
|
||||||
|
new AcceptAllPathFilter()),
|
||||||
|
patternPath);
|
||||||
|
|
||||||
|
for(int i=0; i < globResults.length; i++) {
|
||||||
|
globResults[i] = wrap.makeQualified(globResults[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(globResults.length, 3);
|
||||||
|
assertEquals(USER_DIR + "/a;" + USER_DIR + "/abc;" + USER_DIR + "/abc.p",
|
||||||
|
TestPath.mergeStatuses(globResults));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelativePathOnFS() throws Exception {
|
||||||
|
testOnFileSystem(new TestRelativePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelativePathOnFC() throws Exception {
|
||||||
|
testOnFileContext(new TestRelativePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue