hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1171234 - in /hadoop/common/branches/branch-0.20-security-205: ./ src/core/org/apache/hadoop/security/token/ src/hdfs/org/apache/hadoop/hdfs/ src/test/org/apache/hadoop/hdfs/security/
Date Thu, 15 Sep 2011 19:29:08 GMT
Author: omalley
Date: Thu Sep 15 19:29:08 2011
New Revision: 1171234

URL: http://svn.apache.org/viewvc?rev=1171234&view=rev
Log:
HADOOP-7625. Fix TestDelegationToken by having DFSClient set the service
correctly and having the test cases use the common jar. (omalley)

Modified:
    hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
    hadoop/common/branches/branch-0.20-security-205/build.xml
    hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/security/token/Token.java
    hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
    hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java

Modified: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Thu Sep 15 19:29:08 2011
@@ -145,6 +145,9 @@ Release 0.20.205.0 - 2011.09.12
     HADOOP-7602. wordcount, sort etc on har files fails with NPE.
     (John George via jitendra)
 
+    HADOOP-7625. Fix TestDelegationToken by having DFSClient set the service
+    correctly and having the test cases use the common jar. (omalley)
+
   IMPROVEMENTS
 
     MAPREDUCE-2187. Reporter sends progress during sort/merge. (Anupam Seth via

Modified: hadoop/common/branches/branch-0.20-security-205/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/build.xml?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/build.xml (original)
+++ hadoop/common/branches/branch-0.20-security-205/build.xml Thu Sep 15 19:29:08 2011
@@ -328,6 +328,7 @@
     <pathelement location="${build.tools}"/>
     <pathelement path="${clover.jar}"/>
     <path refid="test.lib.classpath"/>
+    <pathelement location="${hadoop-core.jar}"/>
     <path refid="classpath"/>
   </path>
 
@@ -864,7 +865,7 @@
   <!-- ================================================================== -->
   <!--                                                                    -->
   <!-- ================================================================== -->
-  <target name="jar-test" depends="compile-core-test" description="Make hadoop-test.jar">
+  <target name="jar-test" depends="jar,compile-core-test" description="Make hadoop-test.jar">
     <jar jarfile="${build.dir}/${test.final.name}.jar"
          basedir="${test.build.classes}">
          <manifest>

Modified: hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/security/token/Token.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/security/token/Token.java?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/security/token/Token.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/security/token/Token.java
Thu Sep 15 19:29:08 2011
@@ -126,8 +126,11 @@ public class Token<T extends TokenIdenti
    * @param newKind
    */
   @InterfaceAudience.Private
-  public void setKind(Text newKind) {
+  public synchronized void setKind(Text newKind) {
     kind = newKind;
+    // removed the cached renewer so that it will be looked up with the new
+    // kind.
+    renewer = null;
   }
 
   /**

Modified: hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
Thu Sep 15 19:29:08 2011
@@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.server.dat
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
 import org.apache.hadoop.hdfs.server.namenode.NotReplicatedYetException;
 import org.apache.hadoop.security.AccessControlException;
+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.SecretManager.InvalidToken;
@@ -76,6 +77,7 @@ public class DFSClient implements FSCons
   private static final int TCP_WINDOW_SIZE = 128 * 1024; // 128 KB
   public final ClientProtocol namenode;
   private final ClientProtocol rpcNamenode;
+  private final InetSocketAddress nnAddress;
   final UserGroupInformation ugi;
   volatile boolean clientRunning = true;
   Random r = new Random();
@@ -194,6 +196,7 @@ public class DFSClient implements FSCons
     throws IOException {
     this.conf = conf;
     this.stats = stats;
+    this.nnAddress = nameNodeAddr;
     this.socketTimeout = conf.getInt("dfs.socket.timeout", 
                                      HdfsConstants.READ_TIMEOUT);
     this.datanodeWriteTimeout = conf.getInt("dfs.datanode.socket.write.timeout",
@@ -296,6 +299,7 @@ public class DFSClient implements FSCons
       throws IOException {
     Token<DelegationTokenIdentifier> result =
       namenode.getDelegationToken(renewer);
+    SecurityUtil.setTokenService(result, nnAddress);
     LOG.info("Created " + stringifyToken(result));
     return result;
   }

Modified: hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
Thu Sep 15 19:29:08 2011
@@ -578,7 +578,6 @@ public class DistributedFileSystem exten
                                                       ) throws IOException {
     Token<DelegationTokenIdentifier> result =
       dfs.getDelegationToken(renewer == null ? null : new Text(renewer));
-    result.setService(new Text(getCanonicalServiceName()));
     return result;
   }
 
@@ -598,7 +597,7 @@ public class DistributedFileSystem exten
   @Deprecated
   public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
       throws IOException {
-    return dfs.getDelegationToken(renewer);
+    return getDelegationToken(renewer.toString());
   }
 
   /**

Modified: hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java?rev=1171234&r1=1171233&r2=1171234&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java
Thu Sep 15 19:29:08 2011
@@ -27,6 +27,8 @@ import java.security.PrivilegedException
 
 import junit.framework.Assert;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
@@ -42,9 +44,9 @@ import org.apache.hadoop.hdfs.security.t
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mortbay.log.Log;
 
 public class TestDelegationToken {
+  private static final Log LOG = LogFactory.getLog(TestDelegationToken.class);
   private MiniDFSCluster cluster;
   Configuration config;
   
@@ -99,7 +101,7 @@ public class TestDelegationToken {
     identifier.readFields(new DataInputStream(
              new ByteArrayInputStream(tokenId)));
     Assert.assertTrue(null != dtSecretManager.retrievePassword(identifier));
-    Log.info("Sleep to expire the token");
+    LOG.info("Sleep to expire the token");
 	  Thread.sleep(6000);
 	  //Token should be expired
 	  try {
@@ -110,7 +112,7 @@ public class TestDelegationToken {
 	    //Success
 	  }
 	  dtSecretManager.renewToken(token, "JobTracker");
-	  Log.info("Sleep beyond the max lifetime");
+	  LOG.info("Sleep beyond the max lifetime");
 	  Thread.sleep(5000);
 	  try {
   	  dtSecretManager.renewToken(token, "JobTracker");
@@ -152,7 +154,7 @@ public class TestDelegationToken {
     byte[] tokenId = token.getIdentifier();
     identifier.readFields(new DataInputStream(
              new ByteArrayInputStream(tokenId)));
-    Log.info("A valid token should have non-null password, and should be renewed successfully");
+    LOG.info("A valid token should have non-null password, and should be renewed successfully");
     Assert.assertTrue(null != dtSecretManager.retrievePassword(identifier));
     dtSecretManager.renewToken(token, "JobTracker");
   }
@@ -166,6 +168,8 @@ public class TestDelegationToken {
         .createRemoteUser("JobTracker/foo.com@FOO.COM");
     final UserGroupInformation shortUgi = UserGroupInformation
         .createRemoteUser("JobTracker");
+    LOG.info("cluster at: " + dfs.getUri() + 
+             " token for: " + token.getService());
     longUgi.doAs(new PrivilegedExceptionAction<Object>() {
       public Object run() throws IOException {
         final DistributedFileSystem dfs = (DistributedFileSystem) cluster
@@ -174,6 +178,7 @@ public class TestDelegationToken {
           //try renew with long name
           dfs.renewDelegationToken(token);
         } catch (IOException e) {
+          LOG.error("caught unexpected exception out of renew", e);
           Assert.fail("Could not renew delegation token for user "+longUgi);
         }
         return null;



Mime
View raw message