From 0c7f4cddce4cfa187c48f7fd6366b901ae2fddf4 Mon Sep 17 00:00:00 2001 From: Konstantin Shvachko Date: Tue, 7 Feb 2012 00:53:14 +0000 Subject: [PATCH] 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.23@1241298 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../org/apache/hadoop/hdfs/server/namenode/FSDirectory.java | 5 +---- .../apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java | 5 ++--- .../apache/hadoop/hdfs/server/namenode/CreateEditsLog.java | 4 +++- .../org/apache/hadoop/hdfs/server/namenode/TestEditLog.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 04acb3aef9e..55e908304bd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1565,6 +1565,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-2877. If locking of a storage dir fails, it will remove the other diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java index b956ce0b2ff..923e578dab6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java @@ -333,12 +333,9 @@ public 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); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java index 07bc62f5be0..7a85d2b5223 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java @@ -203,9 +203,8 @@ public class FSEditLogLoader { addCloseOp.mtime, addCloseOp.atime, blockSize, addCloseOp.clientName, addCloseOp.clientMachine); } else { - fsDir.updateFile(oldFile, - addCloseOp.path, permissions, blocks, replication, - addCloseOp.mtime, addCloseOp.atime, blockSize); + fsDir.updateFile(oldFile, addCloseOp.path, blocks, + addCloseOp.mtime, addCloseOp.atime); if(addCloseOp.opCode == FSEditLogOpCodes.OP_CLOSE) { // OP_CLOSE assert oldFile.isUnderConstruction() : "File is not under construction: " + addCloseOp.path; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java index 818b2aacc15..4d098152833 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java @@ -93,7 +93,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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java index 1b01a2fb0f3..bc40e030a84 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLog.java @@ -128,8 +128,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(); } }