HADOOP-8616. ViewFS configuration requires a trailing slash. Contributed by Sandy Ryza.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1392709 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2cc97b78a7
commit
b9131749aa
|
@ -50,6 +50,9 @@ Release 2.0.3-alpha - Unreleased
|
||||||
HADOOP-8855. SSL-based image transfer does not work when Kerberos
|
HADOOP-8855. SSL-based image transfer does not work when Kerberos
|
||||||
is disabled. (todd via eli)
|
is disabled. (todd via eli)
|
||||||
|
|
||||||
|
HADOOP-8616. ViewFS configuration requires a trailing slash. (Sandy Ryza
|
||||||
|
via atm)
|
||||||
|
|
||||||
Release 2.0.2-alpha - 2012-09-07
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -89,7 +89,11 @@ class ChRootedFileSystem extends FilterFileSystem {
|
||||||
public ChRootedFileSystem(final URI uri, Configuration conf)
|
public ChRootedFileSystem(final URI uri, Configuration conf)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
super(FileSystem.get(uri, conf));
|
super(FileSystem.get(uri, conf));
|
||||||
chRootPathPart = new Path(uri.getPath());
|
String pathString = uri.getPath();
|
||||||
|
if (pathString.isEmpty()) {
|
||||||
|
pathString = "/";
|
||||||
|
}
|
||||||
|
chRootPathPart = new Path(pathString);
|
||||||
chRootPathPartString = chRootPathPart.toUri().getPath();
|
chRootPathPartString = chRootPathPart.toUri().getPath();
|
||||||
myUri = uri;
|
myUri = uri;
|
||||||
workingDir = getHomeDirectory();
|
workingDir = getHomeDirectory();
|
||||||
|
|
|
@ -205,9 +205,13 @@ public class ViewFs extends AbstractFileSystem {
|
||||||
protected
|
protected
|
||||||
AbstractFileSystem getTargetFileSystem(final URI uri)
|
AbstractFileSystem getTargetFileSystem(final URI uri)
|
||||||
throws URISyntaxException, UnsupportedFileSystemException {
|
throws URISyntaxException, UnsupportedFileSystemException {
|
||||||
|
String pathString = uri.getPath();
|
||||||
|
if (pathString.isEmpty()) {
|
||||||
|
pathString = "/";
|
||||||
|
}
|
||||||
return new ChRootedFs(
|
return new ChRootedFs(
|
||||||
AbstractFileSystem.createFileSystem(uri, config),
|
AbstractFileSystem.createFileSystem(uri, config),
|
||||||
new Path(uri.getPath()));
|
new Path(pathString));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -343,6 +343,15 @@ public class TestChRootedFileSystem {
|
||||||
verify(mockFs).delete(eq(rawPath), eq(true));
|
verify(mockFs).delete(eq(rawPath), eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testURIEmptyPath() throws IOException {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
|
||||||
|
|
||||||
|
URI chrootUri = URI.create("mockfs://foo");
|
||||||
|
new ChRootedFileSystem(chrootUri, conf);
|
||||||
|
}
|
||||||
|
|
||||||
static class MockFileSystem extends FilterFileSystem {
|
static class MockFileSystem extends FilterFileSystem {
|
||||||
MockFileSystem() {
|
MockFileSystem() {
|
||||||
super(mock(FileSystem.class));
|
super(mock(FileSystem.class));
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.hadoop.fs.viewfs;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.FileContext;
|
||||||
|
import org.apache.hadoop.fs.FsConstants;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class TestViewFsURIs {
|
||||||
|
@Test
|
||||||
|
public void testURIEmptyPath() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
ConfigUtil.addLink(conf, "/user", new URI("file://foo"));
|
||||||
|
|
||||||
|
FileContext.getFileContext(FsConstants.VIEWFS_URI, conf);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue