hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r818676 - in /hadoop/hdfs/branches/HDFS-265: ./ src/java/org/apache/hadoop/hdfs/server/namenode/ src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/
Date Fri, 25 Sep 2009 00:34:42 GMT
Author: shv
Date: Fri Sep 25 00:34:41 2009
New Revision: 818676

URL: http://svn.apache.org/viewvc?rev=818676&view=rev
Log:
HDFS-652. Replace BlockInfo.isUnderConstruction() with isComplete(). Contributed by Konstantin
Shvachko.

Modified:
    hadoop/hdfs/branches/HDFS-265/CHANGES.txt
    hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockInfo.java
    hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
    hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
    hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/hdfs/branches/HDFS-265/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBlockUnderConstruction.java

Modified: hadoop/hdfs/branches/HDFS-265/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/CHANGES.txt?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/CHANGES.txt (original)
+++ hadoop/hdfs/branches/HDFS-265/CHANGES.txt Fri Sep 25 00:34:41 2009
@@ -55,6 +55,8 @@
     HDFS-589. Change block write protocol to support pipeline recovery. 
     (hairong)  
 
+    HDFS-652. Replace BlockInfo.isUnderConstruction() with isComplete() (shv)
+
   BUG FIXES
 
     HDFS-547. TestHDFSFileSystemContract#testOutputStreamClosedTwice

Modified: hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockInfo.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockInfo.java?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockInfo.java
(original)
+++ hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockInfo.java
Fri Sep 25 00:34:41 2009
@@ -284,10 +284,12 @@
   }
 
   /**
-   * Is this block being constructed?
+   * Is this block complete?
+   * 
+   * @return true if the state of the block is {@link BlockUCState#COMPLETE}
    */
-  boolean isUnderConstruction() {
-    return !getBlockUCState().equals(BlockUCState.COMPLETE);
+  boolean isComplete() {
+    return getBlockUCState().equals(BlockUCState.COMPLETE);
   }
 
   /**
@@ -297,7 +299,7 @@
    */
   BlockInfoUnderConstruction convertToBlockUnderConstruction(
       BlockUCState s, DatanodeDescriptor[] targets) {
-    if(!isUnderConstruction()) {
+    if(isComplete()) {
       return new BlockInfoUnderConstruction(
           this, getINode().getReplication(), s, targets);
     }

Modified: hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
(original)
+++ hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/BlockManager.java
Fri Sep 25 00:34:41 2009
@@ -254,7 +254,7 @@
     BlockInfo lastBlock = fileINode.getLastBlock();
     if(lastBlock == null)
       return; // no blocks in file yet
-    if(!lastBlock.isUnderConstruction())
+    if(lastBlock.isComplete())
       return; // already completed (e.g. by syncBlock)
     assert lastBlock.getNumBytes() <= commitBlock.getNumBytes() :
       "commitBlock length is less than the stored one "
@@ -274,7 +274,7 @@
     if(blkIndex < 0)
       return null;
     BlockInfo curBlock = fileINode.getBlocks()[blkIndex];
-    if(!curBlock.isUnderConstruction())
+    if(curBlock.isComplete())
       return curBlock;
     BlockInfoUnderConstruction ucBlock = (BlockInfoUnderConstruction)curBlock;
     if(ucBlock.numNodes() < minReplication)
@@ -1108,7 +1108,7 @@
 
     // check whether safe replication is reached for the block
     // only complete blocks are counted towards that
-    if(!storedBlock.isUnderConstruction())
+    if(storedBlock.isComplete())
       namesystem.incrementSafeBlockCount(numCurrentReplica);
 
     // if file is under construction, then check whether the block

Modified: hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
(original)
+++ hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
Fri Sep 25 00:34:41 2009
@@ -490,7 +490,7 @@
       break;
     case RBW:
     case RWR:
-      if(storedBlock.isUnderConstruction())
+      if(!storedBlock.isComplete())
         ((BlockInfoUnderConstruction)storedBlock).addReplicaIfNotPresent(
                                                       this, block, rState);
       else

Modified: hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++ hadoop/hdfs/branches/HDFS-265/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Fri Sep 25 00:34:41 2009
@@ -567,14 +567,14 @@
     BlockInfo curBlock;
     while(totalSize<size && iter.hasNext()) {
       curBlock = iter.next();
-      if(curBlock.isUnderConstruction())  continue;
+      if(!curBlock.isComplete())  continue;
       totalSize += addBlock(curBlock, results);
     }
     if(totalSize<size) {
       iter = node.getBlockIterator(); // start from the beginning
       for(int i=0; i<startBlock&&totalSize<size; i++) {
         curBlock = iter.next();
-        if(curBlock.isUnderConstruction())  continue;
+        if(!curBlock.isComplete())  continue;
         totalSize += addBlock(curBlock, results);
       }
     }
@@ -3399,7 +3399,7 @@
         if(blocks == null)
           continue;
         for(BlockInfo b : blocks) {
-          if(b.isUnderConstruction())
+          if(!b.isComplete())
             numUCBlocks++;
         }
       }
@@ -3739,7 +3739,7 @@
       throw new IOException(msg);
     }
     INodeFile fileINode = storedBlock.getINode();
-    if(!fileINode.isUnderConstruction() || !storedBlock.isUnderConstruction()) {
+    if(!fileINode.isUnderConstruction() || storedBlock.isComplete()) {
       String msg = block + 
             " is already commited, file or block is not under construction().";
       LOG.info(msg);

Modified: hadoop/hdfs/branches/HDFS-265/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBlockUnderConstruction.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-265/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBlockUnderConstruction.java?rev=818676&r1=818675&r2=818676&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-265/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBlockUnderConstruction.java
(original)
+++ hadoop/hdfs/branches/HDFS-265/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBlockUnderConstruction.java
Fri Sep 25 00:34:41 2009
@@ -18,7 +18,6 @@
 package org.apache.hadoop.hdfs.server.namenode;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
@@ -94,8 +93,8 @@
     // all blocks but the last two should be regular blocks
     for(; idx < blocks.length - 2; idx++) {
       curBlock = blocks[idx];
-      assertFalse("Block is not under construction: " + curBlock,
-          curBlock.isUnderConstruction());
+      assertTrue("Block is not complete: " + curBlock,
+          curBlock.isComplete());
       assertTrue("Block is not in BlocksMap: " + curBlock,
           ns.blockManager.getStoredBlock(curBlock) == curBlock);
     }
@@ -107,8 +106,8 @@
       assertTrue("Block " + curBlock +
           " isUnderConstruction = " + inode.isUnderConstruction() +
           " expected to be " + isFileOpen,
-          (isFileOpen && !curBlock.isUnderConstruction()) ||
-          (!isFileOpen && curBlock.isUnderConstruction() == 
+          (isFileOpen && curBlock.isComplete()) ||
+          (!isFileOpen && !curBlock.isComplete() == 
             (curBlock.getBlockUCState() ==
               BlockUCState.COMMITTED)));
       assertTrue("Block is not in BlocksMap: " + curBlock,
@@ -117,10 +116,10 @@
 
     // the last block is under construction if the file is not closed
     curBlock = blocks[idx]; // last block
-    assertTrue("Block " + curBlock +
-        " isUnderConstruction = " + inode.isUnderConstruction() +
+    assertEquals("Block " + curBlock +
+        " isComplete = " + curBlock.isComplete() +
         " expected to be " + isFileOpen,
-        curBlock.isUnderConstruction() == isFileOpen);
+        isFileOpen, !curBlock.isComplete());
     assertTrue("Block is not in BlocksMap: " + curBlock,
         ns.blockManager.getStoredBlock(curBlock) == curBlock);
   }



Mime
View raw message