hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r700931 - in /hadoop/core/branches/branch-0.19: ./ CHANGES.txt src/test/org/apache/hadoop/hdfs/TestReplication.java src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
Date Wed, 01 Oct 2008 21:17:41 GMT
Author: rangadi
Date: Wed Oct  1 14:17:40 2008
New Revision: 700931

URL: http://svn.apache.org/viewvc?rev=700931&view=rev
Log:
HADOOP-4314. Simulated datanodes should not include blocks that are still
being written in their block report. (Raghu Angadi)

Modified:
    hadoop/core/branches/branch-0.19/   (props changed)
    hadoop/core/branches/branch-0.19/CHANGES.txt
    hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestReplication.java
    hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java

Propchange: hadoop/core/branches/branch-0.19/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct  1 14:17:40 2008
@@ -1 +1 @@
-/hadoop/core/trunk:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628
+/hadoop/core/trunk:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628,700923

Modified: hadoop/core/branches/branch-0.19/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/CHANGES.txt?rev=700931&r1=700930&r2=700931&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.19/CHANGES.txt Wed Oct  1 14:17:40 2008
@@ -787,6 +787,9 @@
     HADOOP-3614. Fix a bug that Datanode may use an old GenerationStamp to get
     meta file. (szetszwo)
 
+    HADOOP-4314. Simulated datanodes should not include blocks that are still
+    being written in their block report. (Raghu Angadi)
+
 Release 0.18.1 - 2008-09-17
 
   IMPROVEMENTS

Modified: hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestReplication.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestReplication.java?rev=700931&r1=700930&r2=700931&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestReplication.java
(original)
+++ hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestReplication.java
Wed Oct  1 14:17:40 2008
@@ -35,8 +35,6 @@
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.ipc.RPC;
-import org.apache.hadoop.net.NetUtils;
 
 /**
  * This class tests the replication of a DFS file.
@@ -71,27 +69,11 @@
     Configuration conf = fileSys.getConf();
     ClientProtocol namenode = DFSClient.createNamenode(conf);
       
-    LocatedBlocks locations;
-    boolean isReplicationDone;
-    do {
-      locations = namenode.getBlockLocations(name.toString(),0,Long.MAX_VALUE);
-      isReplicationDone = true;
-      for (LocatedBlock blk : locations.getLocatedBlocks()) {
-        DatanodeInfo[] datanodes = blk.getLocations();
-        if (Math.min(numDatanodes, repl) != datanodes.length) {
-          isReplicationDone=false;
-          LOG.warn("File has "+datanodes.length+" replicas, expecting "
-                   +Math.min(numDatanodes, repl));
-          try {
-            Thread.sleep(15000L);
-          } catch (InterruptedException e) {
-            // nothing
-          }
-          break;
-        }
-      }
-    } while(!isReplicationDone);
-      
+    waitForBlockReplication(name.toString(), namenode, 
+                            Math.min(numDatanodes, repl), -1);
+    
+    LocatedBlocks locations = namenode.getBlockLocations(name.toString(),0,
+                                                         Long.MAX_VALUE);
     boolean isOnSameRack = true, isNotOnSameRack = true;
     for (LocatedBlock blk : locations.getLocatedBlocks()) {
       DatanodeInfo[] datanodes = blk.getLocations();

Modified: hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java?rev=700931&r1=700930&r2=700931&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
(original)
+++ hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
Wed Oct  1 14:17:40 2008
@@ -20,6 +20,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Random;
 
@@ -279,9 +280,14 @@
 
   public synchronized Block[] getBlockReport() {
     Block[] blockTable = new Block[blockMap.size()];
-    int i = 0;
-    for (Block b: blockMap.keySet()) {  
-      blockTable[i++] = blockMap.get(b).theBlock;
+    int count = 0;
+    for (BInfo b : blockMap.values()) {
+      if (b.isFinalized()) {
+        blockTable[count++] = b.theBlock;
+      }
+    }
+    if (count != blockTable.length) {
+      blockTable = Arrays.copyOf(blockTable, count);
     }
     return blockTable;
   }



Mime
View raw message