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/03/04 04:59:50 UTC

svn commit: r1077285 - in /hadoop/common/branches/branch-0.20-security-patches/src: hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java

Author: omalley
Date: Fri Mar  4 03:59:50 2011
New Revision: 1077285

URL: http://svn.apache.org/viewvc?rev=1077285&view=rev
Log:
commit 74d1ed917972b45bd5f4ea4f86164af7b25ecfc3
Author: Jitendra Nath Pandey <jitendra@sufferhome-lm.(none)>
Date:   Thu Mar 4 00:55:53 2010 -0800

    HDFS-1015 from https://issues.apache.org/jira/secure/attachment/12437830/HDFS-1015-y20.1.patch
    
    +++ b/YAHOO-CHANGES.txt
    +    HDFS-1015. Intermittent failure in TestSecurityTokenEditLog. (jitendra)
    +

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java?rev=1077285&r1=1077284&r2=1077285&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java Fri Mar  4 03:59:50 2011
@@ -204,6 +204,14 @@ public class DelegationTokenSecretManage
     }
     currentTokens.remove(identifier);
   }
+  
+  /**
+   * Returns the number of delegation keys currently stored.
+   * @return number of delegation keys
+   */
+  public synchronized int getNumberOfKeys() {
+    return allKeys.size();
+  }
 
   /**
    * Private helper methods to save delegation keys and tokens in fsimage

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java?rev=1077285&r1=1077284&r2=1077285&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java Fri Mar  4 03:59:50 2011
@@ -33,6 +33,7 @@ import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.hdfs.server.namenode.FSEditLog.EditLogFileInputStream;
+import org.mortbay.log.Log;
 
 /**
  * This class tests the creation and validation of a checkpoint.
@@ -95,7 +96,6 @@ public class TestSecurityTokenEditLog ex
       cluster.waitActive();
       fileSys = cluster.getFileSystem();
       final FSNamesystem namesystem = cluster.getNameNode().getNamesystem();
-      namesystem.getDelegationTokenSecretManager().startThreads();
   
       for (Iterator<File> it = cluster.getNameDirs().iterator(); it.hasNext(); ) {
         File dir = new File(it.next().getPath());
@@ -109,6 +109,7 @@ public class TestSecurityTokenEditLog ex
       editLog.setBufferCapacity(2048);
       editLog.close();
       editLog.open();
+      namesystem.getDelegationTokenSecretManager().startThreads();
     
       // Create threads and make them run transactions concurrently.
       Thread threadId[] = new Thread[NUM_THREADS];
@@ -128,13 +129,13 @@ public class TestSecurityTokenEditLog ex
       } 
       
       editLog.close();
-      editLog.open();
   
       // Verify that we can read in all the transactions that we have written.
       // If there were any corruptions, it is likely that the reading in
       // of these transactions will throw an exception.
       //
       namesystem.getDelegationTokenSecretManager().stopThreads();
+      int numKeys = namesystem.getDelegationTokenSecretManager().getNumberOfKeys();
       for (Iterator<StorageDirectory> it = 
               fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
         File editFile = FSImage.getImageFile(it.next(), NameNodeFile.EDITS);
@@ -142,9 +143,9 @@ public class TestSecurityTokenEditLog ex
         int numEdits = FSEditLog.loadFSEdits(
                                   new EditLogFileInputStream(editFile));
         assertTrue("Verification for " + editFile + " failed. " +
-                   "Expected " + (NUM_THREADS * opsPerTrans * NUM_TRANSACTIONS + 2) + " transactions. "+
+                   "Expected " + (NUM_THREADS * opsPerTrans * NUM_TRANSACTIONS + numKeys) + " transactions. "+
                    "Found " + numEdits + " transactions.",
-                   numEdits == NUM_THREADS * opsPerTrans * NUM_TRANSACTIONS +2);
+                   numEdits == NUM_THREADS * opsPerTrans * NUM_TRANSACTIONS +numKeys);
   
       }
     } finally {