hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1338489 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/server/namenode/ src/test/java/org/apache/hadoop/hdfs/server/namenode/
Date Tue, 15 May 2012 00:31:36 GMT
Author: todd
Date: Tue May 15 00:31:35 2012
New Revision: 1338489

URL: http://svn.apache.org/viewvc?rev=1338489&view=rev
Log:
HDFS-2759. Pre-allocate HDFS edit log files after writing version number. Contributed by Aaron
T. Myers.

Modified:
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileOutputStream.java

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1338489&r1=1338488&r2=1338489&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Tue May 15
00:31:35 2012
@@ -548,6 +548,9 @@ Release 2.0.0 - UNRELEASED
     HDFS-3031. Fix complete() and getAdditionalBlock() RPCs to be idempotent
     (todd)
 
+    HDFS-2759. Pre-allocate HDFS edit log files after writing version number.
+    (atm)
+
   BREAKDOWN OF HDFS-1623 SUBTASKS
 
     HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java?rev=1338489&r1=1338488&r2=1338489&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java
Tue May 15 00:31:35 2012
@@ -182,10 +182,10 @@ public class EditLogFileOutputStream ext
       LOG.info("Nothing to flush");
       return;
     }
-    preallocate(); // preallocate file if necessary
     doubleBuf.flushTo(fp);
-    fc.force(false); // metadata updates not needed because of preallocation
+    fc.force(false); // metadata updates not needed
     fc.position(fc.position() - 1); // skip back the end-of-file marker
+    preallocate(); // preallocate file if necessary
   }
 
   /**

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileOutputStream.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileOutputStream.java?rev=1338489&r1=1338488&r2=1338489&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileOutputStream.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileOutputStream.java
Tue May 15 00:31:35 2012
@@ -41,6 +41,7 @@ import org.mockito.Mockito;
 
 public class TestEditLogFileOutputStream {
   
+  private final static long PREALLOCATION_LENGTH = (1024 * 1024) + 4;
   private final static int HEADER_LEN = 17;
   private static final File TEST_EDITS =
     new File(System.getProperty("test.build.data","/tmp"),
@@ -65,8 +66,9 @@ public class TestEditLogFileOutputStream
     assertEquals("Edit log should contain a header as valid length",
         HEADER_LEN, validation.getValidLength());
     assertEquals(1, validation.getNumTransactions());
-    assertEquals("Edit log should have 1MB of bytes allocated",
-        1024*1024, editLog.length());
+    assertEquals("Edit log should have 1MB pre-allocated, plus 4 bytes " +
+        "for the version number",
+        PREALLOCATION_LENGTH, editLog.length());
     
 
     cluster.getFileSystem().mkdirs(new Path("/tmp"),
@@ -79,8 +81,8 @@ public class TestEditLogFileOutputStream
         validation.getValidLength() > oldLength);
     assertEquals(2, validation.getNumTransactions());
 
-    assertEquals("Edit log should be 1MB long",
-        1024 * 1024, editLog.length());
+    assertEquals("Edit log should be 1MB long, plus 4 bytes for the version number",
+        PREALLOCATION_LENGTH, editLog.length());
     // 256 blocks for the 1MB of preallocation space
     assertTrue("Edit log disk space used should be at least 257 blocks",
         256 * 4096 <= new DU(editLog, conf).getUsed());



Mime
View raw message