hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r637722 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/FSNamesystem.java
Date Mon, 17 Mar 2008 05:18:19 GMT
Author: dhruba
Date: Sun Mar 16 22:18:16 2008
New Revision: 637722

URL: http://svn.apache.org/viewvc?rev=637722&view=rev
Log:
HADOOP-2976. When a lease expires, the Namenode ensures that
blocks of the file are adequately replicated. (dhruba)


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=637722&r1=637721&r2=637722&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Sun Mar 16 22:18:16 2008
@@ -227,6 +227,9 @@
 
     HADOOP-2679. Fix a typo in libhdfs.  (Jason via dhruba)
 
+    HADOOP-2976. When a lease expires, the Namenode ensures that 
+    blocks of the file are adequately replicated. (dhruba)
+
 Release 0.16.1 - 2008-03-13
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?rev=637722&r1=637721&r2=637722&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Sun Mar 16 22:18:16
2008
@@ -1280,8 +1280,17 @@
 
     // Now that the file is real, we need to be sure to replicate
     // the blocks.
-    int numExpectedReplicas = pendingFile.getReplication();
-    Block[] pendingBlocks = pendingFile.getBlocks();
+    checkReplicationFactor(newFile);
+    return COMPLETE_SUCCESS;
+  }
+
+  /** 
+   * Check all blocks of a file. If any blocks are lower than their intended
+   * replication factor, then insert them into neededReplication
+   */
+  private void checkReplicationFactor(INodeFile file) {
+    int numExpectedReplicas = file.getReplication();
+    Block[] pendingBlocks = file.getBlocks();
     int nrBlocks = pendingBlocks.length;
     for (int i = 0; i < nrBlocks; i++) {
       // filter out containingNodes that are marked for decommission.
@@ -1293,7 +1302,6 @@
                                numExpectedReplicas);
       }
     }
-    return COMPLETE_SUCCESS;
   }
 
   static Random randBlockId = new Random();
@@ -1822,6 +1830,9 @@
 
     // close file and persist block allocations for this file
     dir.closeFile(src, newFile);
+
+    // replicate blocks of this file.
+    checkReplicationFactor(newFile);
   
     NameNode.stateChangeLog.debug("DIR* NameSystem.internalReleaseCreate: " + 
                                   src + " is no longer written to by " + 



Mime
View raw message