hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r752609 - in /hadoop/core/trunk: CHANGES.txt src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
Date Wed, 11 Mar 2009 20:57:13 GMT
Author: hairong
Date: Wed Mar 11 20:57:13 2009
New Revision: 752609

URL: http://svn.apache.org/viewvc?rev=752609&view=rev
Log:
HADOOP-5412. Simulated DataNode should not write to a block that's being written by another
thread. Contributed by Hairong Kuang.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=752609&r1=752608&r2=752609&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Mar 11 20:57:13 2009
@@ -2084,6 +2084,9 @@
     HADOOP-5134. FSNamesystem#commitBlockSynchronization adds under-construction
     block locations to blocksMap. (Dhruba Borthakur via hairong)
 
+    HADOOP-5412. Simulated DataNode should not write to a block that's being
+    written by another thread. (hairong)
+
 Release 0.18.3 - 2009-01-27
 
   IMPROVEMENTS

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java?rev=752609&r1=752608&r2=752609&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java
(original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java
Wed Mar 11 20:57:13 2009
@@ -171,7 +171,7 @@
       
       cluster = new MiniDFSCluster(0, conf, numDataNodes*2, false,
                                    true, null, null);
-      
+      cluster.waitActive();
       Set<Block> uniqueBlocks = new HashSet<Block>();
       for (int i=0; i<blocksList.length; ++i) {
         for (int j=0; j < blocksList[i].length; ++j) {

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java?rev=752609&r1=752608&r2=752609&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
(original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
Wed Mar 11 20:57:13 2009
@@ -275,7 +275,9 @@
   }
 
   public synchronized void unfinalizeBlock(Block b) throws IOException {
-    blockMap.remove(b);
+    if (isBeingWritten(b)) {
+      blockMap.remove(b);
+    }
   }
 
   public synchronized Block[] getBlockReport() {
@@ -365,6 +367,15 @@
     return binfo.isFinalized();
   }
 
+  /* check if a block is created but not finalized */
+  private synchronized boolean isBeingWritten(Block b) {
+    BInfo binfo = blockMap.get(b);
+    if (binfo == null) {
+      return false;
+    }
+    return !binfo.isFinalized();  
+  }
+  
   public String toString() {
     return getStorageInfo();
   }
@@ -376,6 +387,10 @@
           throw new BlockAlreadyExistsException("Block " + b + 
               " is valid, and cannot be written to.");
       }
+    if (isBeingWritten(b)) {
+        throw new BlockAlreadyExistsException("Block " + b + 
+            " is being written, and cannot be written to.");
+    }
       BInfo binfo = new BInfo(b, true);
       blockMap.put(b, binfo);
       SimulatedOutputStream crcStream = new SimulatedOutputStream();



Mime
View raw message