You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ma...@apache.org on 2011/12/15 10:00:18 UTC

svn commit: r1214663 - in /hadoop/common/branches/branch-1: ./ src/hdfs/org/apache/hadoop/hdfs/ src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/ src/test/org/apache/hadoop/hdfs/security/token/

Author: mattf
Date: Thu Dec 15 09:00:17 2011
New Revision: 1214663

URL: http://svn.apache.org/viewvc?rev=1214663&view=rev
Log:
HDFS-2589. Remove unnecessary hftp token fetch and renewal thread. Contributed by Daryn Sharp.

Added:
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
      - copied unchanged from r1214661, hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
Modified:
    hadoop/common/branches/branch-1/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
    hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1214663&r1=1214662&r2=1214663&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Thu Dec 15 09:00:17 2011
@@ -181,6 +181,9 @@ Release 1.0.0 - unreleased
 
   BUG FIXES
 
+    HDFS-2589. Remove unnecessary hftp token fetch and renewal thread.
+    (Daryn Sharp via mattf)
+
     MAPREDUCE-3475. JT can't renew its own tokens. (Daryn Sharp via mattf)
 
     HADOOP-7869. HADOOP_HOME warning happens all of the time (Owen O'Malley

Propchange: hadoop/common/branches/branch-1/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 15 09:00:17 2011
@@ -3,7 +3,7 @@
 /hadoop/common/branches/branch-0.20-security-203/CHANGES.txt:1096071,1097011,1097249,1097269,1097281,1097966,1098816,1098819,1098823,1098827,1098832,1098839,1098854,1098863,1099088,1099191,1099324,1099330,1099333,1102071,1128115
 /hadoop/common/branches/branch-0.20-security-204/CHANGES.txt:1128390,1147228,1148069,1149316,1152887,1154413,1159730,1161741
 /hadoop/common/branches/branch-0.20-security-205/CHANGES.txt:1170696,1171234,1171294,1174368,1174370,1174917,1176042,1176248,1176638,1176645,1200050,1200078,1200199,1202378,1203419,1205530
-/hadoop/common/branches/branch-1.0/CHANGES.txt:1208934,1209370,1211431,1211738,1214655,1214658
+/hadoop/common/branches/branch-1.0/CHANGES.txt:1208934,1209370,1211431,1211738,1214655,1214658,1214661
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
 /hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746925,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752514,752555,752590,752609,752834,752836,752913,752932,753112-753113,753346,754645,754847,754927,755035,755226,755348,755370,755418,755426,755790,755905,755938,755986,755998,756352,757448,757624,757849,758156,758180,759398,759932,760502,760783,761046,761482,761632,762216,762879,763107,763502,764967,765016,765809,765951,771607,772844,772876,772884,772920,773889,776638,778962,778966,779893,781720,784661,785046,785569

Modified: hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java?rev=1214663&r1=1214662&r2=1214663&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java (original)
+++ hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java Thu Dec 15 09:00:17 2011
@@ -81,12 +81,12 @@ public class HftpFileSystem extends File
 
   static {
     HttpURLConnection.setFollowRedirects(true);
-    dtRenewer.start();
   }
 
   public static final Text TOKEN_KIND = new Text("HFTP delegation");
   
   protected UserGroupInformation ugi; 
+  private boolean remoteIsInsecure = false;
   private URI hftpURI;
 
   protected InetSocketAddress nnAddr;
@@ -150,10 +150,6 @@ public class HftpFileSystem extends File
     this.nnAddr = getNamenodeAddr(name);
     this.nnSecureAddr = getNamenodeSecureAddr(name);
     this.hftpURI = DFSUtil.createUri(name.getScheme(), nnAddr);
-    
-    if (UserGroupInformation.isSecurityEnabled()) {
-      initDelegationToken();
-    }
   }
   
   protected void initDelegationToken() throws IOException {
@@ -229,6 +225,7 @@ public class HftpFileSystem extends File
             " using https.");
             LOG.debug("error was ", e);
             //Maybe the server is in unsecure mode (that's bad but okay)
+            remoteIsInsecure = true;
             return null;
           }
           for (Token<? extends TokenIdentifier> t : c.getAllTokens()) {
@@ -296,6 +293,9 @@ public class HftpFileSystem extends File
     String tokenString = null;
     if (UserGroupInformation.isSecurityEnabled()) {
       synchronized (this) {
+        if (delegationToken == null && !remoteIsInsecure) {
+          initDelegationToken();
+        }    
         if (delegationToken != null) {
           tokenString = delegationToken.encodeToUrlString();
           return (query + JspHelper.getDelegationTokenUrlParam(tokenString));

Modified: hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java?rev=1214663&r1=1214662&r2=1214663&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java (original)
+++ hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java Thu Dec 15 09:00:17 2011
@@ -139,9 +139,15 @@ public class DelegationTokenRenewer<T ex
     setDaemon(true);
   }
 
+  @Override
+  public void start() {
+    return; // lazy start when addRenewAction is actually called
+  }
+  
   /** Add a renew action to the queue. */
   public void addRenewAction(final T fs) {
     queue.add(new RenewAction<T>(fs));
+    if (!isAlive()) super.start();
   }
 
   @Override