Skip to content

Commit 63226de

Browse files
committed
HADOOP-8408. MR doesn't work with a non-default ViewFS mount table and security enabled. Contributed by Aaron T. Myers
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1339970 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3214d79 commit 63226de

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ Release 2.0.1-alpha - UNRELEASED
183183

184184
HADOOP-8287. etc/hadoop is missing hadoop-env.sh (eli)
185185

186+
HADOOP-8408. MR doesn't work with a non-default ViewFS mount table
187+
and security enabled. (atm via eli)
188+
186189
Release 2.0.0-alpha - UNRELEASED
187190

188191
INCOMPATIBLE CHANGES

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ public Path getTrashCanLocation(final Path f) throws FileNotFoundException {
233233
fsState.resolve(getUriPath(f), true);
234234
return res.isInternalDir() ? null : res.targetFileSystem.getHomeDirectory();
235235
}
236+
237+
@Override
238+
public String getCanonicalServiceName() {
239+
return getUri().getHost();
240+
}
236241

237242
@Override
238243
public URI getUri() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.fs.viewfs;
19+
20+
import static org.junit.Assert.*;
21+
22+
import java.io.IOException;
23+
import java.net.URI;
24+
import java.net.URISyntaxException;
25+
26+
import org.apache.hadoop.conf.Configuration;
27+
import org.apache.hadoop.fs.FileSystem;
28+
import org.apache.hadoop.fs.FsConstants;
29+
import org.junit.Test;
30+
31+
/**
32+
* Test ViewFileSystem's support for having delegation tokens fetched and cached
33+
* for the file system.
34+
*/
35+
public class TestViewFileSystemDelegationTokenSupport {
36+
37+
private static final String MOUNT_TABLE_NAME = "vfs-cluster";
38+
39+
/**
40+
* Ensure that a canonical service name can be determined for ViewFileSystem
41+
* instances configured with a non-default mount table name.
42+
*
43+
* Regression test for HADOOP-8408.
44+
*/
45+
@Test
46+
public void testGetCanonicalServiceNameWithNonDefaultMountTable()
47+
throws URISyntaxException, IOException {
48+
49+
Configuration conf = new Configuration();
50+
ConfigUtil.addLink(conf, MOUNT_TABLE_NAME, "/user", new URI("file:///"));
51+
52+
FileSystem viewFs = FileSystem.get(new URI(FsConstants.VIEWFS_SCHEME +
53+
"://" + MOUNT_TABLE_NAME), conf);
54+
55+
String serviceName = viewFs.getCanonicalServiceName();
56+
assertNotNull(serviceName);
57+
assertEquals(MOUNT_TABLE_NAME, serviceName);
58+
}
59+
60+
@Test
61+
public void testGetCanonicalServiceNameWithDefaultMountTable()
62+
throws URISyntaxException, IOException {
63+
64+
Configuration conf = new Configuration();
65+
ConfigUtil.addLink(conf, "/user", new URI("file:///"));
66+
67+
FileSystem viewFs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
68+
69+
String serviceName = viewFs.getCanonicalServiceName();
70+
assertNull(serviceName);
71+
}
72+
73+
}

0 commit comments

Comments
 (0)