hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1214661 - in /hadoop/common/branches/branch-1.0: ./ src/hdfs/org/apache/hadoop/hdfs/ src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/ src/test/org/apache/hadoop/hdfs/security/token/
Date Thu, 15 Dec 2011 08:58:34 GMT
Author: mattf
Date: Thu Dec 15 08:58:33 2011
New Revision: 1214661

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

Added:
    hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
Modified:
    hadoop/common/branches/branch-1.0/CHANGES.txt
    hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
    hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java

Modified: hadoop/common/branches/branch-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/CHANGES.txt?rev=1214661&r1=1214660&r2=1214661&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1.0/CHANGES.txt Thu Dec 15 08:58:33 2011
@@ -61,6 +61,9 @@ Release 1.0.0 - 2011.11.27
 
   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

Modified: hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java?rev=1214661&r1=1214660&r2=1214661&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
(original)
+++ hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
Thu Dec 15 08:58:33 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.0/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java?rev=1214661&r1=1214660&r2=1214661&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java
(original)
+++ hadoop/common/branches/branch-1.0/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenRenewer.java
Thu Dec 15 08:58:33 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

Added: hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java?rev=1214661&view=auto
==============================================================================
--- hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
(added)
+++ hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/hdfs/security/token/TestDelegationTokenRenewer.java
Thu Dec 15 08:58:33 2011
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.security.token;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.hadoop.hdfs.HftpFileSystem;
+import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenRenewer;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class TestDelegationTokenRenewer {
+
+  @Test
+  public void testLazyRenewerStartup() {
+    DelegationTokenRenewer<HftpFileSystem> dtr =
+        new DelegationTokenRenewer<HftpFileSystem>(HftpFileSystem.class);
+    assertFalse(dtr.isAlive());
+    dtr.start();
+    assertFalse(dtr.isAlive());
+    dtr.addRenewAction(null);
+    assertTrue(dtr.isAlive());
+  }
+}
\ No newline at end of file



Mime
View raw message