hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1036310 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java
Date Thu, 18 Nov 2010 01:37:28 GMT
Author: eli
Date: Thu Nov 18 01:37:28 2010
New Revision: 1036310

URL: http://svn.apache.org/viewvc?rev=1036310&view=rev
Log:
HDFS-1487. FSDirectory.removeBlock() should update diskspace count of the block owner node.
Contributed by Zhong Wang.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1036310&r1=1036309&r2=1036310&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Nov 18 01:37:28 2010
@@ -386,6 +386,9 @@ Release 0.22.0 - Unreleased
 
     HDFS-1507. TestAbandonBlock should abandon a block. (eli)
 
+    HDFS-1487. FSDirectory.removeBlock() should update diskspace count 
+    of the block owner node (Zhong Wang via eli).
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=1036310&r1=1036309&r2=1036310&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Thu
Nov 18 01:37:28 2010
@@ -453,6 +453,11 @@ class FSDirectory implements Closeable {
             +path+" with "+block
             +" block is added to the file system");
       }
+
+      // update space consumed
+      INode[] pathINodes = getExistingPathINodes(path);
+      updateCount(pathINodes, pathINodes.length-1, 0,
+          -fileNode.getPreferredBlockSize()*fileNode.getReplication(), true);
     } finally {
       writeUnlock();
     }

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java?rev=1036310&r1=1036309&r2=1036310&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestAbandonBlock.java Thu Nov 18
01:37:28 2010
@@ -23,9 +23,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.*;
+import org.apache.hadoop.hdfs.protocol.FSConstants;
 import org.apache.hadoop.hdfs.protocol.LocatedBlock;
 import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
+import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
 
+import static org.junit.Assert.*;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -76,4 +79,30 @@ public class TestAbandonBlock {
     // And close the file
     fout.close();
   }
+
+  @Test
+  /** Make sure that the quota is decremented correctly when a block is abandoned */
+  public void testQuotaUpdatedWhenBlockAbandoned() throws IOException {
+    DistributedFileSystem dfs = (DistributedFileSystem)fs;
+    // Setting diskspace quota to 3MB
+    dfs.setQuota(new Path("/"), FSConstants.QUOTA_DONT_SET, 3 * 1024 * 1024);
+
+    // Start writing a file with 2 replicas to ensure each datanode has one.
+    // Block Size is 1MB.
+    String src = FILE_NAME_PREFIX + "test_quota1";
+    FSDataOutputStream fout = fs.create(new Path(src), true, 4096, (short)2, 1024 * 1024);
+    for (int i = 0; i < 1024; i++) {
+      fout.writeByte(123);
+    }
+
+    // Shutdown one datanode, causing the block abandonment.
+    cluster.getDataNodes().get(0).shutdown();
+
+    // Close the file, new block will be allocated with 2MB pending size.
+    try {
+      fout.close();
+    } catch (QuotaExceededException e) {
+      fail("Unexpected quota exception when closing fout");
+    }
+  }
 }



Mime
View raw message