Author: jitendra
Date: Tue Oct 4 06:51:39 2011
New Revision: 1178702
URL: http://svn.apache.org/viewvc?rev=1178702&view=rev
Log:
Previous commit for HDFS-2392 was incomplete, reverting.
Modified:
hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (contents,
props changed)
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestHftpFileSystem.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=1178702&r1=1178701&r2=1178702&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Tue Oct 4
06:51:39 2011
@@ -254,8 +254,6 @@ Release 0.20.205.0 - 2011.09.28
HADOOP-7715. Removed unnecessary security logger configuration. (Eric Yang)
- HDFS-2392. Dist with hftp is failing again. (Daryn Sharp via jitendra)
-
IMPROVEMENTS
MAPREDUCE-2928. MR-2413 improvements (Eli Collins via mattf)
Propchange: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Oct 4 06:51:39 2011
@@ -1,6 +1,6 @@
/hadoop/common/branches/branch-0.20/CHANGES.txt:826138,826568,829987,831184,833001,880632,898713,909245,909723,960946,990003,1044225
/hadoop/common/branches/branch-0.20-append/CHANGES.txt:955380,955398,955448,956329
-/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074,1178698
+/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074
/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/core/branches/branch-0.18/CHANGES.txt:727226
Modified:
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java?rev=1178702&r1=1178701&r2=1178702&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
(original)
+++
hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
Tue Oct 4 06:51:39 2011
@@ -155,42 +155,31 @@ public class HftpFileSystem extends File
this.hftpURI = createUri(name.getScheme(), nnAddr);
if (UserGroupInformation.isSecurityEnabled()) {
- initDelegationToken();
- }
- }
-
- protected void initDelegationToken() throws IOException {
- // look for hftp token, then try hdfs
- Token<?> token = selectHftpDelegationToken();
- if (token == null) {
- token = selectHdfsDelegationToken();
- }
-
- //since we don't already have a token, go get one over https
- boolean createdToken = false;
- if (token == null) {
- token = getDelegationToken(null);
- createdToken = (token != null);
- }
-
- // security might be disabled
- if (token != null) {
- setDelegationToken(token);
- if (createdToken) {
- renewer.addTokenToRenew(this);
- LOG.debug("Created new DT for " + token.getService());
+ Token<?> token = selectHftpDelegationToken();
+ if (token == null) {
+ token = selectHdfsDelegationToken();
+ }
+ //since we don't already have a token, go get one over https
+ if (token == null) {
+ token = getDelegationToken(null);
+ // security might be disabled
+ if (token != null) {
+ setDelegationToken(token);
+ renewer.addTokenToRenew(this);
+ LOG.debug("Created new DT for " + token.getService());
+ }
} else {
LOG.debug("Found existing DT for " + token.getService());
}
}
}
- protected Token<DelegationTokenIdentifier> selectHftpDelegationToken() {
+ private Token<DelegationTokenIdentifier> selectHftpDelegationToken() {
Text serviceName = SecurityUtil.buildTokenService(nnSecureAddr);
return hftpTokenSelector.selectToken(serviceName, ugi.getTokens());
}
- protected Token<DelegationTokenIdentifier> selectHdfsDelegationToken() {
+ private Token<DelegationTokenIdentifier> selectHdfsDelegationToken() {
// this guesses the remote cluster's rpc service port.
// the current token design assumes it's the same as the local cluster's
// rpc port unless a config key is set. there should be a way to automatic
@@ -223,7 +212,7 @@ public class HftpFileSystem extends File
return uri;
}
- protected <T extends TokenIdentifier> void setDelegationToken(Token<T>
token) {
+ private <T extends TokenIdentifier> void setDelegationToken(Token<T> token) {
renewToken = token;
// emulate the 203 usage of the tokens
// by setting the kind and service as if they were hdfs tokens
Modified:
hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestHftpFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestHftpFileSystem.java?rev=1178702&r1=1178701&r2=1178702&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestHftpFileSystem.java
(original)
+++
hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestHftpFileSystem.java
Tue Oct 4 06:51:39 2011
@@ -18,7 +18,6 @@
package org.apache.hadoop.hdfs;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
@@ -26,11 +25,6 @@ import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
-import
org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.security.SecurityUtil;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.security.token.TokenIdentifier;
import org.junit.Before;
import org.junit.Test;
@@ -212,74 +206,4 @@ public class TestHftpFileSystem {
fs.getCanonicalServiceName()
);
}
-
- Token<DelegationTokenIdentifier> hftpToken;
- Token<DelegationTokenIdentifier> hdfsToken;
- Token<DelegationTokenIdentifier> gotToken;
-
- class StubbedHftpFileSystem extends HftpFileSystem {
- @Override
- protected Token<DelegationTokenIdentifier> selectHftpDelegationToken() {
- return hftpToken;
- }
-
- @Override
- protected Token<DelegationTokenIdentifier> selectHdfsDelegationToken() {
- return hdfsToken;
- }
-
- @Override
- public Token<DelegationTokenIdentifier> getDelegationToken(String renewer)
{
- return makeDummyToken("new");
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected <T extends TokenIdentifier> void setDelegationToken(Token<T>
token) {
- gotToken = (Token<DelegationTokenIdentifier>) token;
- }
- }
-
- static Token<DelegationTokenIdentifier> makeDummyToken(String kind) {
- Token<DelegationTokenIdentifier> token = new Token();
- token.setKind(new Text(kind));
- return token;
- }
-
- @Before
- public void resetTokens() {
- hftpToken = hdfsToken = gotToken = null;
- }
-
- @Test
- public void testHftpWithNoTokens() throws IOException {
- new StubbedHftpFileSystem().initDelegationToken();
- assertNotNull(gotToken);
- assertEquals(new Text("new"), gotToken.getKind());
-
- }
- @Test
- public void testHftpWithHftpToken() throws IOException {
- hftpToken = makeDummyToken("hftp");
- new StubbedHftpFileSystem().initDelegationToken();
- assertNotNull(gotToken);
- assertEquals(gotToken, hftpToken);
- }
-
- @Test
- public void testHftpWithHdfsToken() throws IOException {
- hdfsToken = makeDummyToken("hdfs");
- new StubbedHftpFileSystem().initDelegationToken();
- assertNotNull(gotToken);
- assertEquals(gotToken, hdfsToken);
- }
-
- @Test
- public void testHftpWithHftpAndHdfsToken() throws IOException {
- hftpToken = makeDummyToken("hftp");
- hdfsToken = makeDummyToken("hdfs");
- new StubbedHftpFileSystem().initDelegationToken();
- assertNotNull(gotToken);
- assertEquals(gotToken, hftpToken);
- }
}
\ No newline at end of file