Przeglądaj źródła

HDFS-2886. CreateEditLogs should generate a realistic edit log. Contributed by Konstantin Shvachko.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1241312 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 13 lat temu
rodzic
commit
ea91db5b05

+ 2 - 0
hdfs/CHANGES.txt

@@ -12,6 +12,8 @@ Release 0.22.1 - Unreleased
 
     HDFS-2718. Optimize OP_ADD in edits loading. (shv)
 
+    HDFS-2886. CreateEditLogs should generate a realistic edit log. (shv)
+
   BUG FIXES
 
     HDFS-1910. NameNode should not save fsimage twice. (shv)

+ 1 - 4
hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

@@ -303,12 +303,9 @@ class FSDirectory implements Closeable {
    */
   void updateFile(INodeFile file,
                   String path,
-                  PermissionStatus permissions,
                   BlockInfo[] blocks, 
-                  short replication,
                   long mtime,
-                  long atime,
-                  long preferredBlockSize) throws IOException {
+                  long atime) throws IOException {
 
     // Update the salient file attributes.
     file.setAccessTime(atime);

+ 1 - 3
hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java

@@ -216,9 +216,7 @@ public class FSEditLogLoader {
                 path, permissions, blocks, replication,
                 mtime, atime, blockSize, clientName, clientMachine);
           } else {
-            fsDir.updateFile(oldFile,
-                path, permissions, blocks, replication,
-                mtime, atime, blockSize);
+            fsDir.updateFile(oldFile, path,  blocks, mtime, atime);
             if(opcode == Ops.OP_CLOSE) {  // OP_CLOSE
               assert oldFile.isUnderConstruction() : 
                 "File is not under construction: " + path;

+ 3 - 1
hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java

@@ -92,7 +92,9 @@ public class CreateEditsLog {
         dirInode = new INodeDirectory(p, 0L);
         editLog.logMkDir(currentDir, dirInode);
       }
-      editLog.logOpenFile(filePath, inode);
+      editLog.logOpenFile(filePath, 
+          new INodeFileUnderConstruction(
+              p, replication, 0, blockSize, "", "", null));
       editLog.logCloseFile(filePath, inode);
 
       if (currentBlockId - bidAtSync >= 2000) { // sync every 2K blocks

+ 2 - 3
hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java

@@ -83,8 +83,8 @@ public class TestEditLog extends TestCase {
       for (int i = 0; i < numTransactions; i++) {
         INodeFileUnderConstruction inode = new INodeFileUnderConstruction(
                             p, replication, blockSize, 0, "", "", null);
-        editLog.logOpenFile("/filename" + startIndex + i, inode);
-        editLog.logCloseFile("/filename" + startIndex + i, inode);
+        editLog.logOpenFile("/filename" + (startIndex + i), inode);
+        editLog.logCloseFile("/filename" + (startIndex + i), inode);
         editLog.logSync();
       }
     }
@@ -379,5 +379,4 @@ public class TestEditLog extends TestCase {
     originalImage.close();
     fsn.close();
   }
-
 }