You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by su...@apache.org on 2010/03/18 22:27:19 UTC

svn commit: r925004 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java

Author: suresh
Date: Thu Mar 18 21:27:19 2010
New Revision: 925004

URL: http://svn.apache.org/viewvc?rev=925004&view=rev
Log:
HDFS-1015. Fix intermittent failure in TestSecurityTokenEditLog. Contribute by Jitendra Nath Pandey.


Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=925004&r1=925003&r2=925004&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Mar 18 21:27:19 2010
@@ -163,8 +163,8 @@ Trunk (unreleased changes)
     Lipcon via hairong)
 
     HDFS-630. In DFSOutputStream.nextBlockOutputStream(), the client can
-              exclude specific datanodes when locating the next block.
-              (Cosmin Lehene via Stack)
+    exclude specific datanodes when locating the next block.
+    (Cosmin Lehene via Stack)
 
     HDFS-922. Remove unnecessary semicolon added by HDFS-877 that causes
     problems for Eclipse compilation. (jghoman)
@@ -200,6 +200,9 @@ Trunk (unreleased changes)
 
     HDFS-961. dfs_readdir incorrectly parses paths. (Eli Collins via tomwhite)
 
+    HDFS-1015. Fix intermittent failure in TestSecurityTokenEditLog.
+    (Jitendra Nath Pandey via suresh)
+    
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java?rev=925004&r1=925003&r2=925004&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java Thu Mar 18 21:27:19 2010
@@ -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/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java?rev=925004&r1=925003&r2=925004&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSecurityTokenEditLog.java Thu Mar 18 21:27:19 2010
@@ -96,7 +96,6 @@ public class TestSecurityTokenEditLog ex
       cluster.waitActive();
       fileSys = cluster.getFileSystem();
       final FSNamesystem namesystem = cluster.getNamesystem();
-      namesystem.getDelegationTokenSecretManager().startThreads();
   
       for (Iterator<URI> it = cluster.getNameDirs().iterator(); it.hasNext(); ) {
         File dir = new File(it.next().getPath());
@@ -110,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];
@@ -129,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);
@@ -143,9 +143,9 @@ public class TestSecurityTokenEditLog ex
         int numEdits = namesystem.getEditLog().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 {