소스 검색

HDFS-1308. job conf key for the services name of DelegationToken for HFTP url is constructed incorrectly in HFTPFileSystem

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@967292 13f79535-47bb-0310-9956-ffa450edef68
Boris Shkolnik 15 년 전
부모
커밋
3853c13be2
2개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 7 6
      src/java/org/apache/hadoop/hdfs/HftpFileSystem.java

+ 3 - 0
CHANGES.txt

@@ -160,6 +160,9 @@ Trunk (unreleased changes)
     HDFS-1085. HFTP read may fail silently on the client side if there is an
     exception on the server side.  (szetszwo)
 
+    HDFS-1308. job conf key for the services name of DelegationToken for HFTP
+     url is constructed incorrectly in HFTPFileSystem (boryas)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 7 - 6
src/java/org/apache/hadoop/hdfs/HftpFileSystem.java

@@ -47,11 +47,13 @@ import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.server.common.JspHelper;
+import org.apache.hadoop.hdfs.server.namenode.NameNode;
 import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.Credentials;
+import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.TokenIdentifier;
@@ -110,17 +112,16 @@ public class HftpFileSystem extends FileSystem {
     nnAddr = NetUtils.createSocketAddr(name.toString());
     
     if (UserGroupInformation.isSecurityEnabled()) {
-      StringBuffer sb = new StringBuffer(HFTP_SERVICE_NAME_KEY);
       // configuration has the actual service name for this url. Build the key 
       // and get it.
-      final String key = sb.append(NetUtils.normalizeHostName(name.getHost())).
-      append(".").append(name.getPort()).toString();
+      final String key = HftpFileSystem.HFTP_SERVICE_NAME_KEY +
+        SecurityUtil.buildDTServiceName(name, NameNode.DEFAULT_PORT);
 
-      LOG.debug("Trying to find DT for " + name + " using key=" + key + "; conf=" + conf.get(key, ""));
+      LOG.debug("Trying to find DT for " + name + " using key=" + key + 
+          "; conf=" + conf.get(key, ""));
       Text nnServiceNameText = new Text(conf.get(key, ""));
 
-      Collection<Token<? extends TokenIdentifier>> tokens =
-        ugi.getTokens();
+      Collection<Token<? extends TokenIdentifier>> tokens = ugi.getTokens();
       //try finding a token for this namenode (esp applicable for tasks
       //using hftp). If there exists one, just set the delegationField
       for (Token<? extends TokenIdentifier> t : tokens) {