diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5c947b0e68..4a1d09e7e0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -113,6 +113,9 @@ Trunk (unreleased changes) HDFS-2784. Update hftp and hdfs for host-based token support. (Kihwal Lee via jitendra) + HDFS-2785. Update webhdfs and httpfs for host-based token support. + (Robert Joseph Evans via jitendra) + OPTIMIZATIONS HDFS-2477. Optimize computing the diff between a block report and the namenode state. (Tomasz Nykiel via hairong) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java index 3a80206516..c64dfb14e8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java @@ -141,6 +141,7 @@ public static boolean isEnabled(final Configuration conf, final Log log) { private final UserGroupInformation ugi; private InetSocketAddress nnAddr; + private URI uri; private Token delegationToken; private final AuthenticatedURL.Token authToken = new AuthenticatedURL.Token(); private Path workingDir; @@ -158,7 +159,11 @@ public synchronized void initialize(URI uri, Configuration conf ) throws IOException { super.initialize(uri, 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.workingDir = getHomeDirectory(); @@ -203,12 +208,7 @@ protected int getDefaultPort() { @Override public URI getUri() { - try { - return new URI(SCHEME, null, nnAddr.getHostName(), nnAddr.getPort(), - null, null, null); - } catch (URISyntaxException e) { - return null; - } + return this.uri; } /** @return the home directory. */ @@ -810,8 +810,7 @@ private static WebHdfsFileSystem getWebHdfs( final Token token, final Configuration conf ) throws IOException, InterruptedException, URISyntaxException { - final InetSocketAddress nnAddr = NetUtils.createSocketAddr( - token.getService().toString()); + final InetSocketAddress nnAddr = SecurityUtil.getTokenServiceAddr(token); final URI uri = DFSUtil.createUri(WebHdfsFileSystem.SCHEME, nnAddr); return (WebHdfsFileSystem)FileSystem.get(uri, conf); } @@ -821,7 +820,7 @@ public long renew(final Token token, final Configuration conf ) throws IOException, InterruptedException { final UserGroupInformation ugi = UserGroupInformation.getLoginUser(); // update the kerberos credentials, if they are coming from a keytab - ugi.checkTGTAndReloginFromKeytab(); + ugi.reloginFromKeytab(); try { WebHdfsFileSystem webhdfs = getWebHdfs(token, conf);