HDFS-2785. Update webhdfs and httpfs for host-based token support. Contributed by Robert Joseph Evans.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1240460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jitendra Nath Pandey 2012-02-04 06:57:40 +00:00
parent 1de317a945
commit 205f0470f4
2 changed files with 12 additions and 10 deletions

View File

@ -113,6 +113,9 @@ Trunk (unreleased changes)
HDFS-2784. Update hftp and hdfs for host-based token support. HDFS-2784. Update hftp and hdfs for host-based token support.
(Kihwal Lee via jitendra) (Kihwal Lee via jitendra)
HDFS-2785. Update webhdfs and httpfs for host-based token support.
(Robert Joseph Evans via jitendra)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-2477. Optimize computing the diff between a block report and the HDFS-2477. Optimize computing the diff between a block report and the
namenode state. (Tomasz Nykiel via hairong) namenode state. (Tomasz Nykiel via hairong)

View File

@ -141,6 +141,7 @@ public static boolean isEnabled(final Configuration conf, final Log log) {
private final UserGroupInformation ugi; private final UserGroupInformation ugi;
private InetSocketAddress nnAddr; private InetSocketAddress nnAddr;
private URI uri;
private Token<?> delegationToken; private Token<?> delegationToken;
private final AuthenticatedURL.Token authToken = new AuthenticatedURL.Token(); private final AuthenticatedURL.Token authToken = new AuthenticatedURL.Token();
private Path workingDir; private Path workingDir;
@ -158,7 +159,11 @@ public synchronized void initialize(URI uri, Configuration conf
) throws IOException { ) throws IOException {
super.initialize(uri, conf); super.initialize(uri, conf);
setConf(conf); setConf(conf);
try {
this.uri = new URI(uri.getScheme(), uri.getAuthority(), null, null, null);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
this.nnAddr = NetUtils.createSocketAddr(uri.toString()); this.nnAddr = NetUtils.createSocketAddr(uri.toString());
this.workingDir = getHomeDirectory(); this.workingDir = getHomeDirectory();
@ -203,12 +208,7 @@ protected int getDefaultPort() {
@Override @Override
public URI getUri() { public URI getUri() {
try { return this.uri;
return new URI(SCHEME, null, nnAddr.getHostName(), nnAddr.getPort(),
null, null, null);
} catch (URISyntaxException e) {
return null;
}
} }
/** @return the home directory. */ /** @return the home directory. */
@ -810,8 +810,7 @@ private static WebHdfsFileSystem getWebHdfs(
final Token<?> token, final Configuration conf final Token<?> token, final Configuration conf
) throws IOException, InterruptedException, URISyntaxException { ) throws IOException, InterruptedException, URISyntaxException {
final InetSocketAddress nnAddr = NetUtils.createSocketAddr( final InetSocketAddress nnAddr = SecurityUtil.getTokenServiceAddr(token);
token.getService().toString());
final URI uri = DFSUtil.createUri(WebHdfsFileSystem.SCHEME, nnAddr); final URI uri = DFSUtil.createUri(WebHdfsFileSystem.SCHEME, nnAddr);
return (WebHdfsFileSystem)FileSystem.get(uri, conf); return (WebHdfsFileSystem)FileSystem.get(uri, conf);
} }
@ -821,7 +820,7 @@ public long renew(final Token<?> token, final Configuration conf
) throws IOException, InterruptedException { ) throws IOException, InterruptedException {
final UserGroupInformation ugi = UserGroupInformation.getLoginUser(); final UserGroupInformation ugi = UserGroupInformation.getLoginUser();
// update the kerberos credentials, if they are coming from a keytab // update the kerberos credentials, if they are coming from a keytab
ugi.checkTGTAndReloginFromKeytab(); ugi.reloginFromKeytab();
try { try {
WebHdfsFileSystem webhdfs = getWebHdfs(token, conf); WebHdfsFileSystem webhdfs = getWebHdfs(token, conf);