hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r928918 - in /hadoop/hdfs/branches/branch-0.21: ./ .eclipse.templates/.launches/ src/contrib/ src/contrib/hdfsproxy/ src/java/ src/java/org/apache/hadoop/hdfs/protocol/ src/java/org/apache/hadoop/hdfs/server/datanode/ src/test/aop/org/apach...
Date Mon, 29 Mar 2010 22:17:43 GMT
Author: hairong
Date: Mon Mar 29 22:17:43 2010
New Revision: 928918

URL: http://svn.apache.org/viewvc?rev=928918&view=rev
Log:
Merge -c 928917 from trunk to bring the change of HDFS-1067 to branch 0.21.

Modified:
    hadoop/hdfs/branches/branch-0.21/   (props changed)
    hadoop/hdfs/branches/branch-0.21/.eclipse.templates/.launches/   (props changed)
    hadoop/hdfs/branches/branch-0.21/CHANGES.txt   (contents, props changed)
    hadoop/hdfs/branches/branch-0.21/build.xml   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/contrib/build.xml   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/contrib/hdfsproxy/   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/java/   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java
  (props changed)
    hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java
  (props changed)
    hadoop/hdfs/branches/branch-0.21/src/test/aop/org/apache/hadoop/hdfs/protocol/   (props
changed)
    hadoop/hdfs/branches/branch-0.21/src/test/hdfs/   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestInterDatanodeProtocol.java
    hadoop/hdfs/branches/branch-0.21/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
    hadoop/hdfs/branches/branch-0.21/src/webapps/datanode/   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/webapps/hdfs/   (props changed)
    hadoop/hdfs/branches/branch-0.21/src/webapps/secondary/   (props changed)

Propchange: hadoop/hdfs/branches/branch-0.21/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.19/hdfs:713112
 /hadoop/hdfs/branches/HDFS-265:796829-820463
-/hadoop/hdfs/trunk:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/.eclipse.templates/.launches/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1 +1 @@
-/hadoop/hdfs/trunk/.eclipse.templates/.launches:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/.eclipse.templates/.launches:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Modified: hadoop/hdfs/branches/branch-0.21/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/CHANGES.txt?rev=928918&r1=928917&r2=928918&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/hdfs/branches/branch-0.21/CHANGES.txt Mon Mar 29 22:17:43 2010
@@ -331,6 +331,8 @@ Trunk (unreleased changes)
 
     HDFS-520. Create new tests for block recovery. (hairong)
 
+    HDFS-1067. Create block recovery tests that handle errors. (hairong)
+
   BUG FIXES
 
     HDFS-76. Better error message to users when commands fail because of 

Propchange: hadoop/hdfs/branches/branch-0.21/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.19/hdfs/CHANGES.txt:713112
 /hadoop/hdfs/branches/HDFS-265/CHANGES.txt:796829-820463
-/hadoop/hdfs/trunk/CHANGES.txt:817853-817863,818294-818298,818801,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/CHANGES.txt:817853-817863,818294-818298,818801,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/build.xml:713112
 /hadoop/core/trunk/build.xml:779102
 /hadoop/hdfs/branches/HDFS-265/build.xml:796829-820463
-/hadoop/hdfs/trunk/build.xml:817853-817863,818294-818298,818801,824552,824944,825229,826149,828116,828926,829258,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/build.xml:817853-817863,818294-818298,818801,824552,824944,825229,826149,828116,828926,829258,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/contrib/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/contrib/build.xml:713112
 /hadoop/hdfs/branches/HDFS-265/src/contrib/build.xml:796829-820463
-/hadoop/hdfs/trunk/src/contrib/build.xml:817853-817863,818294-818298,818801,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/contrib/build.xml:817853-817863,818294-818298,818801,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/contrib/hdfsproxy/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/contrib/hdfsproxy:713112
 /hadoop/core/trunk/src/contrib/hdfsproxy:776175-784663
 /hadoop/hdfs/branches/HDFS-265/src/contrib/hdfsproxy:796829-820463
-/hadoop/hdfs/trunk/src/contrib/hdfsproxy:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/contrib/hdfsproxy:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/java:713112
 /hadoop/core/trunk/src/hdfs:776175-785643,785929-786278
 /hadoop/hdfs/branches/HDFS-265/src/java:796829-820463
-/hadoop/hdfs/trunk/src/java:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/java:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,5 +1,5 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:713112
 /hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:776175-785643,785929-786278
 /hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:817353-818319,818321-818553
-/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/RecoveryInProgressException.java:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917
 /hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/RecoveryInProgressException.java:796829-800617,800619-803337,804756-805652,808672-809439,811495-813103,813105-813630,814223-815964,818294-818298

Propchange: hadoop/hdfs/branches/branch-0.21/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -3,4 +3,4 @@
 /hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DatanodeBlockInfo.java:776175-785643,785929-786278
 /hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:776175-785643,785929-786278
 /hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:796829-820463
-/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/ReplicaInfo.java:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/test/aop/org/apache/hadoop/hdfs/protocol/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1 +1 @@
-/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/hdfs/protocol:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/hdfs/protocol:817853-817863,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/test/hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/test/hdfs:713112
 /hadoop/core/trunk/src/test/hdfs:776175-785643
 /hadoop/hdfs/branches/HDFS-265/src/test/hdfs:796829-820463
-/hadoop/hdfs/trunk/src/test/hdfs:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/test/hdfs:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Modified: hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestInterDatanodeProtocol.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestInterDatanodeProtocol.java?rev=928918&r1=928917&r2=928918&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestInterDatanodeProtocol.java
(original)
+++ hadoop/hdfs/branches/branch-0.21/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestInterDatanodeProtocol.java
Mon Mar 29 22:17:43 2010
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hdfs.server.datanode;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.List;
@@ -173,14 +174,14 @@ public class TestInterDatanodeProtocol {
       }
     }
 
-    { //replica not found
+    { // BlockRecoveryFI_01: replica not found
       final long recoveryid = gs + 1;
       final Block b = new Block(firstblockid - 1, length, gs);
       ReplicaRecoveryInfo r = FSDataset.initReplicaRecovery(map, b, recoveryid);
       Assert.assertNull("Data-node should not have this replica.", r);
     }
     
-    { //case "THIS IS NOT SUPPOSED TO HAPPEN" with recovery id < gs  
+    { // BlockRecoveryFI_02: "THIS IS NOT SUPPOSED TO HAPPEN" with recovery id < gs  
       final long recoveryid = gs - 1;
       final Block b = new Block(firstblockid + 1, length, gs);
       try {
@@ -192,6 +193,19 @@ public class TestInterDatanodeProtocol {
       }
     }
 
+    // BlockRecoveryFI_03: Replica's gs is less than the block's gs
+    {
+      final long recoveryid = gs + 1;
+      final Block b = new Block(firstblockid, length, gs+1);
+      try {
+        FSDataset.initReplicaRecovery(map, b, recoveryid);
+        fail("InitReplicaRecovery should fail because replica's " +
+        		"gs is less than the block's gs");
+      } catch (IOException e) {
+        e.getMessage().startsWith(
+           "replica.getGenerationStamp() < block.getGenerationStamp(), block=");
+      }
+    }
   }
 
   /** Test {@link FSDataset#updateReplicaUnderRecovery(ReplicaUnderRecovery, long, long)}
*/

Modified: hadoop/hdfs/branches/branch-0.21/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.21/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java?rev=928918&r1=928917&r2=928918&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.21/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
(original)
+++ hadoop/hdfs/branches/branch-0.21/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
Mon Mar 29 22:17:43 2010
@@ -30,9 +30,11 @@ import org.apache.hadoop.hdfs.MiniDFSClu
 import org.apache.hadoop.hdfs.protocol.Block;
 import org.apache.hadoop.hdfs.protocol.DatanodeID;
 import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.RecoveryInProgressException;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.ReplicaState;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
 import org.apache.hadoop.hdfs.server.datanode.DataNode.BlockRecord;
+import org.apache.hadoop.hdfs.server.datanode.FSDatasetInterface.BlockWriteStreams;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
 import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand;
 import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
@@ -42,16 +44,21 @@ import org.apache.hadoop.hdfs.server.pro
 import org.apache.hadoop.hdfs.server.protocol.ReplicaRecoveryInfo;
 import org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringBlock;
 import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.Daemon;
 import org.apache.log4j.Level;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.*;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * This tests if sync all replicas in block recovery works correctly
@@ -313,4 +320,148 @@ public class TestBlockRecovery {
     verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);
     verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen);    
   }  
+
+  private Collection<RecoveringBlock> initRecoveringBlocks() {
+    Collection<RecoveringBlock> blocks = new ArrayList<RecoveringBlock>(1);
+    DatanodeInfo[] locs = new DatanodeInfo[] {
+        new DatanodeInfo(dn.dnRegistration),
+        mock(DatanodeInfo.class) };
+    RecoveringBlock rBlock = new RecoveringBlock(block, locs, RECOVERY_ID);
+    blocks.add(rBlock);
+    return blocks;
+  }
+  /**
+   * BlockRecoveryFI_05. One DN throws RecoveryInProgressException.
+   *
+   * @throws IOException
+   *           in case of an error
+   */
+  @Test
+  public void testRecoveryInProgressException()
+    throws IOException, InterruptedException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    DataNode spyDN = spy(dn);
+    doThrow(new RecoveryInProgressException("Replica recovery is in progress")).
+       when(spyDN).initReplicaRecovery(any(RecoveringBlock.class));
+    Daemon d = spyDN.recoverBlocks(initRecoveringBlocks());
+    d.join();
+    verify(spyDN, never()).syncBlock(
+        any(RecoveringBlock.class), anyListOf(BlockRecord.class));
+  }
+
+  /**
+   * BlockRecoveryFI_06. all datanodes throws an exception.
+   *
+   * @throws IOException
+   *           in case of an error
+   */
+  @Test
+  public void testErrorReplicas() throws IOException, InterruptedException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    DataNode spyDN = spy(dn);
+    doThrow(new IOException()).
+       when(spyDN).initReplicaRecovery(any(RecoveringBlock.class));
+    Daemon d = spyDN.recoverBlocks(initRecoveringBlocks());
+    d.join();
+    verify(spyDN, never()).syncBlock(
+        any(RecoveringBlock.class), anyListOf(BlockRecord.class));
+  }
+
+  /**
+   * BlockRecoveryFI_07. max replica length from all DNs is zero.
+   *
+   * @throws IOException in case of an error
+   */
+  @Test
+  public void testZeroLenReplicas() throws IOException, InterruptedException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    DataNode spyDN = spy(dn);
+    doReturn(new ReplicaRecoveryInfo(block.getBlockId(), 0,
+        block.getGenerationStamp(), ReplicaState.FINALIZED)).when(spyDN).
+        initReplicaRecovery(any(RecoveringBlock.class));
+    Daemon d = spyDN.recoverBlocks(initRecoveringBlocks());
+    d.join();
+    verify(dn.namenode).commitBlockSynchronization(
+        block, RECOVERY_ID, 0, true, true, DatanodeID.EMPTY_ARRAY);
+  }
+
+  private List<BlockRecord> initBlockRecords(DataNode spyDN) {
+    List<BlockRecord> blocks = new ArrayList<BlockRecord>(1);
+    BlockRecord blockRecord = new BlockRecord(
+        new DatanodeID(dn.dnRegistration), spyDN,
+        new ReplicaRecoveryInfo(block.getBlockId(), block.getNumBytes(),
+            block.getGenerationStamp(), ReplicaState.FINALIZED));
+    blocks.add(blockRecord);
+    return blocks;
+  }
+
+  private final static RecoveringBlock rBlock =
+    new RecoveringBlock(block, null, RECOVERY_ID);
+
+  /**
+   * BlockRecoveryFI_09. some/all DNs failed to update replicas.
+   *
+   * @throws IOException in case of an error
+   */
+  @Test
+  public void testFailedReplicaUpdate() throws IOException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    DataNode spyDN = spy(dn);
+    doThrow(new IOException()).when(spyDN).updateReplicaUnderRecovery(
+        block, RECOVERY_ID, block.getNumBytes());
+    try {
+      spyDN.syncBlock(rBlock, initBlockRecords(spyDN));
+      fail("Sync should fail");
+    } catch (IOException e) {
+      e.getMessage().startsWith("Cannot recover ");
+    }
+  }
+
+  /**
+   * BlockRecoveryFI_10. DN has no ReplicaUnderRecovery.
+   *
+   * @throws IOException in case of an error
+   */
+  @Test
+  public void testNoReplicaUnderRecovery() throws IOException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    dn.data.createRbw(block);
+    try {
+      dn.syncBlock(rBlock, initBlockRecords(dn));
+      fail("Sync should fail");
+    } catch (IOException e) {
+      e.getMessage().startsWith("Cannot recover ");
+    }
+    verify(dn.namenode, never()).commitBlockSynchronization(
+        any(Block.class), anyLong(), anyLong(), anyBoolean(),
+        anyBoolean(), any(DatanodeID[].class));
+  }
+
+  /**
+   * BlockRecoveryFI_11. a replica's recovery id does not match new GS.
+   *
+   * @throws IOException in case of an error
+   */
+  @Test
+  public void testNotMatchedReplicaID() throws IOException {
+    LOG.debug("Running " + GenericTestUtils.getMethodName());
+    ReplicaInPipelineInterface replicaInfo = dn.data.createRbw(block);
+    BlockWriteStreams streams = null;
+    try {
+      streams = replicaInfo.createStreams(true, 0, 0);
+      streams.checksumOut.write('a');
+      dn.data.initReplicaRecovery(new RecoveringBlock(block, null, RECOVERY_ID+1));
+      try {
+        dn.syncBlock(rBlock, initBlockRecords(dn));
+        fail("Sync should fail");
+      } catch (IOException e) {
+        e.getMessage().startsWith("Cannot recover ");
+      }
+      verify(dn.namenode, never()).commitBlockSynchronization(
+          any(Block.class), anyLong(), anyLong(), anyBoolean(),
+          anyBoolean(), any(DatanodeID[].class));
+    } finally {
+      streams.close();
+    }
+  }
 }

Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/datanode/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/webapps/datanode:713112
 /hadoop/core/trunk/src/webapps/datanode:776175-784663
 /hadoop/hdfs/branches/HDFS-265/src/webapps/datanode:796829-820463
-/hadoop/hdfs/trunk/src/webapps/datanode:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/webapps/datanode:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/webapps/hdfs:713112
 /hadoop/core/trunk/src/webapps/hdfs:776175-784663
 /hadoop/hdfs/branches/HDFS-265/src/webapps/hdfs:796829-820463
-/hadoop/hdfs/trunk/src/webapps/hdfs:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/webapps/hdfs:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917

Propchange: hadoop/hdfs/branches/branch-0.21/src/webapps/secondary/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 29 22:17:43 2010
@@ -1,4 +1,4 @@
 /hadoop/core/branches/branch-0.19/hdfs/src/webapps/secondary:713112
 /hadoop/core/trunk/src/webapps/secondary:776175-784663
 /hadoop/hdfs/branches/HDFS-265/src/webapps/secondary:796829-820463
-/hadoop/hdfs/trunk/src/webapps/secondary:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794
+/hadoop/hdfs/trunk/src/webapps/secondary:817853-817863,818294-818298,824552,824944,826149,828116,828926,829880,829894,830003,831436,831455-831490,832043,833499,835728,880971,881014,881017,884432,888084,888507,888519,889002,890655,891106,892993,893066,893629,897975,898467,898573,899747,901026,903906,906794,928917



Mime
View raw message