Browse Source

commit f38a79a53335c349b455c1a5483dc5cb4f541a30
Author: Devaraj Das <ddas@yahoo-inc.com>
Date: Fri Mar 19 15:04:20 2010 -0700

HADOOP:6632 from https://issues.apache.org/jira/secure/attachment/12439307/6632.mr.patch

+++ b/YAHOO-CHANGES.txt
+ HADOOP-6632. Fix on JobTracker to reuse filesystem handles if possible.
+ (ddas)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077348 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
099fc9778d

+ 12 - 1
src/mapred/org/apache/hadoop/mapreduce/security/token/DelegationTokenRenewal.java

@@ -19,6 +19,7 @@
 package org.apache.hadoop.mapreduce.security.token;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.URI;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -203,7 +204,17 @@ public class DelegationTokenRenewal {
   throws Exception {
     DistributedFileSystem dfs = null;
     try {
-      final URI uri = new URI (SCHEME + "://" + token.getService().toString());
+      //TODO: The service is usually an IPaddress:port. We convert
+      //it to dns name and then obtain the filesystem just so that
+      //we reuse the existing filesystem handle (that the jobtracker
+      //might have for this namenode; the namenode is usually
+      //specified as the dns name in the jobtracker).
+      //THIS IS A WORKAROUND FOR NOW. NEED TO SOLVE THIS PROBLEM 
+      //IN A BETTER WAY.
+      String[] ipaddr = token.getService().toString().split(":");
+      InetAddress iaddr = InetAddress.getByName(ipaddr[0]);
+      String dnsName = iaddr.getCanonicalHostName();
+      final URI uri = new URI (SCHEME + "://" + dnsName+":"+ipaddr[1]);
       dfs = (DistributedFileSystem)
       UserGroupInformation.getLoginUser().doAs(
           new PrivilegedExceptionAction<DistributedFileSystem>() {