hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1202013 [4/4] - in /hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project: ./ conf/ hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/ hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/mai...
Date Tue, 15 Nov 2011 02:39:22 GMT
Modified: hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java?rev=1202013&r1=1202012&r2=1202013&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Tue Nov 15 02:39:13 2011
@@ -29,7 +29,6 @@ import org.apache.hadoop.security.token.
 import org.apache.hadoop.security.token.SecretManager.InvalidToken;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -48,26 +47,27 @@ public class TestDelegationToken {
     cluster = new MiniMRCluster(0,0,1,"file:///",1);
   }
   
+  @SuppressWarnings("deprecation")
   @Test
-  @Ignore
   public void testDelegationToken() throws Exception {
     
-    JobClient client;
+    final JobClient client;
     client = user1.doAs(new PrivilegedExceptionAction<JobClient>(){
-
       @Override
       public JobClient run() throws Exception {
         return new JobClient(cluster.createJobConf());
-      }});
-    JobClient bobClient;
+      }
+    });
+    
+    final JobClient bobClient;
     bobClient = user2.doAs(new PrivilegedExceptionAction<JobClient>(){
-
       @Override
       public JobClient run() throws Exception {
         return new JobClient(cluster.createJobConf());
-      }});
+      }
+    });
     
-    Token<DelegationTokenIdentifier> token = 
+    final Token<DelegationTokenIdentifier> token = 
       client.getDelegationToken(new Text(user1.getUserName()));
     
     DataInputBuffer inBuf = new DataInputBuffer();
@@ -85,26 +85,58 @@ public class TestDelegationToken {
     System.out.println("max time: " + maxTime);
     assertTrue("createTime < current", createTime < currentTime);
     assertTrue("current < maxTime", currentTime < maxTime);
-    client.renewDelegationToken(token);
-    client.renewDelegationToken(token);
-    try {
-      bobClient.renewDelegationToken(token);
-      Assert.fail("bob renew");
-    } catch (AccessControlException ace) {
-      // PASS
-    }
-    try {
-      bobClient.cancelDelegationToken(token);
-      Assert.fail("bob renew");
-    } catch (AccessControlException ace) {
-      // PASS
-    }
-    client.cancelDelegationToken(token);
-    try {
-      client.cancelDelegationToken(token);
-      Assert.fail("second alice cancel");
-    } catch (InvalidToken it) {
-      // PASS
-    }
+
+    // renew should work as user alice
+    user1.doAs(new PrivilegedExceptionAction<Void>() {
+      @Override
+      public Void run() throws Exception {
+        client.renewDelegationToken(token);
+        client.renewDelegationToken(token);
+        return null;
+      }   
+    });
+    
+    // bob should fail to renew
+    user2.doAs(new PrivilegedExceptionAction<Void>() {
+      @Override
+      public Void run() throws Exception {
+        try {
+          bobClient.renewDelegationToken(token);
+          Assert.fail("bob renew");
+        } catch (AccessControlException ace) {
+          // PASS
+        }
+        return null;
+      }
+    });
+        
+    // bob should fail to cancel
+    user2.doAs(new PrivilegedExceptionAction<Void>() {
+      @Override
+      public Void run() throws Exception {
+        try {
+          bobClient.cancelDelegationToken(token);
+          Assert.fail("bob cancel");
+        } catch (AccessControlException ace) {
+          // PASS
+        }
+        return null;
+      }
+    });
+    
+    // alice should be able to cancel but only cancel once
+    user1.doAs(new PrivilegedExceptionAction<Void>() {
+      @Override
+      public Void run() throws Exception {
+        client.cancelDelegationToken(token);
+        try {
+          client.cancelDelegationToken(token);
+          Assert.fail("second alice cancel");
+        } catch (InvalidToken it) {
+          // PASS
+        }
+        return null;
+      }   
+    });
   }
 }

Propchange: hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 02:39:13 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java:1161333-1196451
+/hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java:1161333-1202009
 /hadoop/core/branches/branch-0.19/mapred/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java:713112
 /hadoop/core/trunk/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java:776175-785643
 /hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/security/authorize/TestServiceLevelAuthorization.java:817878-835934

Propchange: hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 02:39:13 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java:1161333-1196451
+/hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java:1161333-1202009
 /hadoop/core/branches/branch-0.19/mapred/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java:713112
 /hadoop/core/trunk/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java:776175-785643
 /hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/test/MapredTestDriver.java:817878-835934

Modified: hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java?rev=1202013&r1=1202012&r2=1202013&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/tools/org/apache/hadoop/tools/rumen/LoggedTaskAttempt.java
Tue Nov 15 02:39:13 2011
@@ -328,11 +328,27 @@ public class LoggedTaskAttempt implement
     return hostName;
   }
 
-
+  void setHostName(String hostName) {
+    this.hostName = hostName;
+  }
+  
   // hostName is saved in the format rackName/NodeName
   void setHostName(String hostName, String rackName) {
-    this.hostName = hostName == null || rackName == null ? null
-        : rackName.intern() + "/" + hostName.intern();
+    if (hostName == null || hostName.length() == 0) {
+      throw new RuntimeException("Invalid entry! Missing hostname");
+    } else if (rackName == null || rackName.length() == 0) {
+      setHostName(hostName);
+    } else {
+      // make sure that the rackname is prefixed with a '/'
+      if (!rackName.startsWith("/")) {
+        rackName = "/" + rackName;
+      }
+      // make sure that the hostname is prefixed with a '/'
+      if (!hostName.startsWith("/")) {
+        hostName = "/" + hostName;
+      }
+      setHostName(rackName.intern() + hostName.intern());
+    }
   }
 
   public long getHdfsBytesRead() {

Propchange: hadoop/common/branches/HDFS-1623/hadoop-mapreduce-project/src/webapps/job/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 02:39:13 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/hadoop-mapreduce-project/src/webapps/job:1152502-1196451
+/hadoop/common/trunk/hadoop-mapreduce-project/src/webapps/job:1152502-1202009
 /hadoop/core/branches/branch-0.19/mapred/src/webapps/job:713112
 /hadoop/core/trunk/src/webapps/job:776175-785643



Mime
View raw message