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 om...@apache.org on 2011/09/15 21:34:23 UTC
svn commit: r1171236 - in /hadoop/common/branches/branch-0.20-security: ./
src/core/org/apache/hadoop/security/token/ src/hdfs/org/apache/hadoop/hdfs/
src/test/org/apache/hadoop/hdfs/security/
Author: omalley
Date: Thu Sep 15 19:34:22 2011
New Revision: 1171236
URL: http://svn.apache.org/viewvc?rev=1171236&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/CHANGES.txt (contents, props changed)
hadoop/common/branches/branch-0.20-security/build.xml
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/security/token/Token.java
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java
Modified: hadoop/common/branches/branch-0.20-security/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/CHANGES.txt?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security/CHANGES.txt Thu Sep 15 19:34:22 2011
@@ -163,6 +163,9 @@ Release 0.20.205.0 - unreleased
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
Propchange: hadoop/common/branches/branch-0.20-security/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 15 19:34:22 2011
@@ -2,7 +2,7 @@
/hadoop/common/branches/branch-0.20-append/CHANGES.txt:955380,955398,955448,956329
/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,1154413,1159730,1161741
-/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt:1170696
+/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt:1170696,1171234
/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-0.20-security/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/build.xml?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/build.xml (original)
+++ hadoop/common/branches/branch-0.20-security/build.xml Thu Sep 15 19:34:22 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/src/core/org/apache/hadoop/security/token/Token.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/security/token/Token.java?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/security/token/Token.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/security/token/Token.java Thu Sep 15 19:34:22 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/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Thu Sep 15 19:34:22 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/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java Thu Sep 15 19:34:22 2011
@@ -576,7 +576,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;
}
@@ -596,7 +595,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/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java?rev=1171236&r1=1171235&r2=1171236&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/security/TestDelegationToken.java Thu Sep 15 19:34:22 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;