hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r1042517 - in /hadoop/hdfs/trunk: CHANGES.txt src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
Date Mon, 06 Dec 2010 04:34:24 GMT
Author: cos
Date: Mon Dec  6 04:34:24 2010
New Revision: 1042517

URL: http://svn.apache.org/viewvc?rev=1042517&view=rev
Log:
HDFS-1502. TestBlockRecovery triggers NPE in assert. Contributed by Hairong Kuang.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1042517&r1=1042516&r2=1042517&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon Dec  6 04:34:24 2010
@@ -426,6 +426,8 @@ Release 0.22.0 - Unreleased
 
     HDFS-1523. TestLargeBlock is failing on trunk. (cos)
 
+    HDFS-1502. TestBlockRecovery triggers NPE in assert. (hairong via cos)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java?rev=1042517&r1=1042516&r2=1042517&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
(original)
+++ hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
Mon Dec  6 04:34:24 2010
@@ -128,7 +128,8 @@ public class TestBlockRecovery {
   private void testSyncReplicas(ReplicaRecoveryInfo replica1, 
       ReplicaRecoveryInfo replica2,
       InterDatanodeProtocol dn1,
-      InterDatanodeProtocol dn2) throws IOException {
+      InterDatanodeProtocol dn2,
+      long expectLen) throws IOException {
     
     DatanodeInfo[] locs = new DatanodeInfo[]{
         mock(DatanodeInfo.class), mock(DatanodeInfo.class)};
@@ -141,6 +142,13 @@ public class TestBlockRecovery {
         new DatanodeID("aa", "bb", 11, 22), dn2, replica2);
     syncList.add(record1);
     syncList.add(record2);
+    
+    when(dn1.updateReplicaUnderRecovery((Block)anyObject(), anyLong(), 
+        anyLong())).thenReturn(new Block(block.getBlockId(), 
+            expectLen, block.getGenerationStamp()));
+    when(dn2.updateReplicaUnderRecovery((Block)anyObject(), anyLong(), 
+        anyLong())).thenReturn(new Block(block.getBlockId(), 
+            expectLen, block.getGenerationStamp()));
     dn.syncBlock(rBlock, syncList);
   }
   
@@ -162,7 +170,7 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);    
 
@@ -173,7 +181,7 @@ public class TestBlockRecovery {
         REPLICA_LEN2, GEN_STAMP-2, ReplicaState.FINALIZED);
 
     try {
-      testSyncReplicas(replica1, replica2, dn1, dn2);
+      testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
       Assert.fail("Two finalized replicas should not have different lengthes!");
     } catch (IOException e) {
       Assert.assertTrue(e.getMessage().startsWith(
@@ -201,7 +209,7 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     
@@ -214,7 +222,7 @@ public class TestBlockRecovery {
     dn1 = mock(InterDatanodeProtocol.class);
     dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2, never()).updateReplicaUnderRecovery(
         block, RECOVERY_ID, REPLICA_LEN1);
@@ -240,7 +248,7 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2, never()).updateReplicaUnderRecovery(
         block, RECOVERY_ID, REPLICA_LEN1);
@@ -254,7 +262,7 @@ public class TestBlockRecovery {
     dn1 = mock(InterDatanodeProtocol.class);
     dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2, never()).updateReplicaUnderRecovery(
         block, RECOVERY_ID, REPLICA_LEN1);
@@ -278,8 +286,8 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
     long minLen = Math.min(REPLICA_LEN1, REPLICA_LEN2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, minLen);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);
     verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);    
   }
@@ -302,7 +310,7 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1);
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1);
     verify(dn2, never()).updateReplicaUnderRecovery(
         block, RECOVERY_ID, REPLICA_LEN1);    
@@ -326,9 +334,9 @@ public class TestBlockRecovery {
     InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class);
     InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class);
 
-    testSyncReplicas(replica1, replica2, dn1, dn2);
-    
     long minLen = Math.min(REPLICA_LEN1, REPLICA_LEN2);
+    testSyncReplicas(replica1, replica2, dn1, dn2, minLen);
+    
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);
     verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);    
   }  



Mime
View raw message