hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r831170 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java
Date Fri, 30 Oct 2009 00:28:47 GMT
Author: shv
Date: Fri Oct 30 00:28:47 2009
New Revision: 831170

URL: http://svn.apache.org/viewvc?rev=831170&view=rev
Log:
HDFS-736. commitBlockSynchronization() updates block GS and length in-place. Contributed by
Konstantin Shvachko.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=831170&r1=831169&r2=831170&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Fri Oct 30 00:28:47 2009
@@ -318,9 +318,12 @@
 
     HDFS-730. Add 4 fault injection tests to simulate non-responsive datanode
     and out-of-memory problem for pipeline close ack.  (szetszwo)
-    
+
     HDFS-728. Create a comprehensive functional test for append. (hairong)
 
+    HDFS-736. commitBlockSynchronization() updates block GS and length in-place.
+    (shv)
+
   BUG FIXES
 
     HDFS-76. Better error message to users when commands fail because of 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=831170&r1=831169&r2=831170&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Fri
Oct 30 00:28:47 2009
@@ -2047,19 +2047,19 @@
           + ", closeFile=" + closeFile
           + ", deleteBlock=" + deleteblock
           + ")");
-    final BlockInfo oldblockinfo = blockManager.getStoredBlock(lastblock);
-    if (oldblockinfo == null) {
+    final BlockInfo storedBlock = blockManager.getStoredBlock(lastblock);
+    if (storedBlock == null) {
       throw new IOException("Block (=" + lastblock + ") not found");
     }
-    INodeFile iFile = oldblockinfo.getINode();
-    if (!iFile.isUnderConstruction() || oldblockinfo.isComplete()) {
+    INodeFile iFile = storedBlock.getINode();
+    if (!iFile.isUnderConstruction() || storedBlock.isComplete()) {
       throw new IOException("Unexpected block (=" + lastblock
           + ") since the file (=" + iFile.getLocalName()
           + ") is not under construction");
     }
 
     long recoveryId =
-      ((BlockInfoUnderConstruction)oldblockinfo).getBlockRecoveryId();
+      ((BlockInfoUnderConstruction)storedBlock).getBlockRecoveryId();
     if(recoveryId != newgenerationstamp) {
       throw new IOException("The recovery id " + newgenerationstamp
           + " does not match current recovery id "
@@ -2068,21 +2068,14 @@
         
     INodeFileUnderConstruction pendingFile = (INodeFileUnderConstruction)iFile;
 
-
-    // Remove old block from blocks map. This always have to be done
-    // because the generation stamp of this block is changing.
-    blockManager.removeBlockFromMap(oldblockinfo);
-
     if (deleteblock) {
       pendingFile.removeLastBlock(lastblock);
+      blockManager.removeBlockFromMap(storedBlock);
     }
     else {
-      // update last block, construct newblockinfo and add it to the blocks map
-      lastblock.set(lastblock.getBlockId(), newlength, newgenerationstamp);
-      BlockInfoUnderConstruction newblockinfo = 
-        new BlockInfoUnderConstruction(
-            lastblock, pendingFile.getReplication());
-      blockManager.addINode(newblockinfo, pendingFile);
+      // update last block
+      storedBlock.setGenerationStamp(newgenerationstamp);
+      storedBlock.setNumBytes(newlength);
 
       // find the DatanodeDescriptor objects
       // There should be no locations in the blockManager till now because the
@@ -2099,11 +2092,11 @@
         // Otherwise fsck will report these blocks as MISSING, especially if the
         // blocksReceived from Datanodes take a long time to arrive.
         for (int i = 0; i < descriptors.length; i++) {
-          descriptors[i].addBlock(newblockinfo);
+          descriptors[i].addBlock(storedBlock);
         }
       }
-      // add locations into the INodeUnderConstruction
-      pendingFile.setLastBlock(newblockinfo, descriptors);
+      // add pipeline locations into the INodeUnderConstruction
+      pendingFile.setLastBlock(storedBlock, descriptors);
     }
 
     // If this commit does not want to close the file, persist
@@ -2119,7 +2112,7 @@
     }
 
     // commit the last block
-    blockManager.commitLastBlock(pendingFile, lastblock);
+    blockManager.commitLastBlock(pendingFile, storedBlock);
 
     //remove lease, close file
     finalizeINodeFileUnderConstruction(src, pendingFile);

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java?rev=831170&r1=831169&r2=831170&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java Fri Oct
30 00:28:47 2009
@@ -218,19 +218,6 @@
     return blocks[blocks.length - 2];
   }
 
-  // SHV !!! this is not used anywhere - remove
-  INodeFileUnderConstruction toINodeFileUnderConstruction(
-      String clientName, String clientMachine, DatanodeDescriptor clientNode
-      ) throws IOException {
-    if (isUnderConstruction()) {
-      return (INodeFileUnderConstruction)this;
-    }
-    return new INodeFileUnderConstruction(name,
-        blockReplication, modificationTime, preferredBlockSize,
-        blocks, getPermissionStatus(),
-        clientName, clientMachine, clientNode);
-  }
-
   /**
    * Get the last block of the file.
    * Make sure it has the right type.



Mime
View raw message