hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgho...@apache.org
Subject svn commit: r935778 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java
Date Tue, 20 Apr 2010 00:48:51 GMT
Author: jghoman
Date: Tue Apr 20 00:48:51 2010
New Revision: 935778

URL: http://svn.apache.org/viewvc?rev=935778&view=rev
Log:
HDFS-1014: Error in reading delegation tokens from edit logs. Contributed by Jitendra Nath
Pandey.


Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=935778&r1=935777&r2=935778&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Tue Apr 20 00:48:51 2010
@@ -261,6 +261,9 @@ Trunk (unreleased changes)
     HDFS-651. HDFS Docs - fix listing of docs in the doc menu.
     (Corinne Chandel via tomwhite)
 
+    HDFS-1014. Error in reading delegation tokens from edit logs.
+    (Jitendra Nath Pandey via jhoman)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java?rev=935778&r1=935777&r2=935778&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java Tue Apr
20 00:48:51 2010
@@ -431,9 +431,6 @@ public class FSEditLog {
         numOpRenewDelegationToken = 0, numOpCancelDelegationToken = 0, 
         numOpUpdateMasterKey = 0, numOpOther = 0;
 
-    DelegationTokenIdentifier delegationTokenId = new DelegationTokenIdentifier();
-    DelegationKey delegationKey = new DelegationKey();
-
     try {
       while (true) {
         long timestamp = 0;
@@ -748,6 +745,8 @@ public class FSEditLog {
                 + " for version " + logVersion);
           }
           numOpGetDelegationToken++;
+          DelegationTokenIdentifier delegationTokenId = 
+              new DelegationTokenIdentifier();
           delegationTokenId.readFields(in);
           long expiryTime = readLong(in);
           fsNamesys.getDelegationTokenSecretManager()
@@ -760,6 +759,8 @@ public class FSEditLog {
                 + " for version " + logVersion);
           }
           numOpRenewDelegationToken++;
+          DelegationTokenIdentifier delegationTokenId = 
+              new DelegationTokenIdentifier();
           delegationTokenId.readFields(in);
           long expiryTime = readLong(in);
           fsNamesys.getDelegationTokenSecretManager()
@@ -772,6 +773,8 @@ public class FSEditLog {
                 + " for version " + logVersion);
           }
           numOpCancelDelegationToken++;
+          DelegationTokenIdentifier delegationTokenId = 
+              new DelegationTokenIdentifier();
           delegationTokenId.readFields(in);
           fsNamesys.getDelegationTokenSecretManager()
               .updatePersistedTokenCancellation(delegationTokenId);
@@ -783,6 +786,7 @@ public class FSEditLog {
                 + " for version " + logVersion);
           }
           numOpUpdateMasterKey++;
+          DelegationKey delegationKey = new DelegationKey();
           delegationKey.readFields(in);
           fsNamesys.getDelegationTokenSecretManager().updatePersistedMasterKey(
               delegationKey);

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java?rev=935778&r1=935777&r2=935778&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckPointForSecurityTokens.java
Tue Apr 20 00:48:51 2010
@@ -45,6 +45,7 @@ public class TestCheckPointForSecurityTo
   static final int fileSize = 8192;
   static final int numDatanodes = 3;
   short replication = 3;
+  MiniDFSCluster cluster = null;
 
   NameNode startNameNode( Configuration conf,
                           String imageDirs,
@@ -59,13 +60,22 @@ public class TestCheckPointForSecurityTo
     Assert.assertTrue(nn.isInSafeMode());
     return nn;
   }
-
+  
+  private void cancelToken(Token<DelegationTokenIdentifier> token)
+      throws IOException {
+    cluster.getNamesystem().cancelDelegationToken(token);
+  }
+  
+  private void renewToken(Token<DelegationTokenIdentifier> token)
+      throws IOException {
+      cluster.getNamesystem().renewDelegationToken(token);
+  }
+  
   /**
    * Tests save namepsace.
    */
   @Test
   public void testSaveNamespace() throws IOException {
-    MiniDFSCluster cluster = null;
     DistributedFileSystem fs = null;
     try {
       Configuration conf = new HdfsConfiguration();
@@ -75,8 +85,10 @@ public class TestCheckPointForSecurityTo
       FSNamesystem namesystem = cluster.getNamesystem();
       namesystem.getDelegationTokenSecretManager().startThreads();
       String renewer = UserGroupInformation.getLoginUser().getUserName();
-      Token<DelegationTokenIdentifier> token = namesystem
+      Token<DelegationTokenIdentifier> token1 = namesystem
           .getDelegationToken(new Text(renewer)); 
+      Token<DelegationTokenIdentifier> token2 = namesystem
+          .getDelegationToken(new Text(renewer));
       
       // Saving image without safe mode should fail
       DFSAdmin admin = new DFSAdmin(conf);
@@ -102,7 +114,7 @@ public class TestCheckPointForSecurityTo
         Assert.assertTrue(new File(ed, "current/edits").length() == Integer.SIZE/Byte.SIZE);
       }
 
-      // restart cluster and verify file exists
+      // restart cluster
       cluster.shutdown();
       cluster = null;
 
@@ -110,11 +122,66 @@ public class TestCheckPointForSecurityTo
       cluster.waitActive();
       //Should be able to renew & cancel the delegation token after cluster restart
       try {
-        cluster.getNamesystem().renewDelegationToken(token);
-        cluster.getNamesystem().cancelDelegationToken(token);
+        renewToken(token1);
+        renewToken(token2);
+      } catch (IOException e) {
+        Assert.fail("Could not renew or cancel the token");
+      }
+
+      namesystem = cluster.getNamesystem();
+      namesystem.getDelegationTokenSecretManager().startThreads();
+      Token<DelegationTokenIdentifier> token3 = namesystem
+          .getDelegationToken(new Text(renewer));
+      Token<DelegationTokenIdentifier> token4 = namesystem
+          .getDelegationToken(new Text(renewer));
+
+      // restart cluster again
+      cluster.shutdown();
+      cluster = null;
+
+      cluster = new MiniDFSCluster(conf, numDatanodes, false, null);
+      cluster.waitActive();
+
+      namesystem = cluster.getNamesystem();
+      namesystem.getDelegationTokenSecretManager().startThreads();
+      Token<DelegationTokenIdentifier> token5 = namesystem
+          .getDelegationToken(new Text(renewer));
+
+      try {
+        renewToken(token1);
+        renewToken(token2);
+        renewToken(token3);
+        renewToken(token4);
+        renewToken(token5);
+
+      } catch (IOException e) {
+        Assert.fail("Could not renew or cancel the token");
+      }
+
+      // restart cluster again
+      cluster.shutdown();
+      cluster = null;
+
+      cluster = new MiniDFSCluster(conf, numDatanodes, false, null);
+      cluster.waitActive();
+
+      namesystem = cluster.getNamesystem();
+      namesystem.getDelegationTokenSecretManager().startThreads();
+      try {
+        renewToken(token1);
+        cancelToken(token1);
+        renewToken(token2);
+        cancelToken(token2);
+        renewToken(token3);
+        cancelToken(token3);
+        renewToken(token4);
+        cancelToken(token4);
+        renewToken(token5);
+        cancelToken(token5);
       } catch (IOException e) {
         Assert.fail("Could not renew or cancel the token");
       }
+
     } finally {
       if(fs != null) fs.close();
       if(cluster!= null) cluster.shutdown();



Mime
View raw message