diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 4be73fb0ffb..d864198942b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -224,6 +224,9 @@ Release 2.0.5-beta - UNRELEASED HDFS-4748. MiniJournalCluster#restartJournalNode leaks resources, which causes sporadic test failures. (Chris Nauroth via suresh) + HDFS-4785. Concat operation does not remove concatenated files from + InodeMap. (suresh) + Release 2.0.4-alpha - UNRELEASED INCOMPATIBLE CHANGES 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 a9ffad0632e..04ab803323b 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 @@ -971,6 +971,7 @@ public class FSDirectory implements Closeable { nodeToRemove.setBlocks(null); trgParent.removeChild(nodeToRemove); + inodeMap.remove(nodeToRemove); count++; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java index 35ffb52e1de..bf693db3b14 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java @@ -443,8 +443,27 @@ public class TestINodeFile { assertTrue(fs.delete(renamedPath, true)); inodeCount -= 2; assertEquals(inodeCount, fsn.dir.getInodeMapSize()); + + // Create and concat /test/file1 /test/file2 + // Create /test1/file1 and /test1/file2 + String file1 = "/test1/file1"; + String file2 = "/test1/file2"; + DFSTestUtil.createFile(fs, new Path(file1), 512, (short) 1, 0); + DFSTestUtil.createFile(fs, new Path(file2), 512, (short) 1, 0); + inodeCount += 3; // test1, file1 and file2 are created + expectedLastInodeId += 3; + assertEquals(inodeCount, fsn.dir.getInodeMapSize()); + assertEquals(expectedLastInodeId, fsn.getLastInodeId()); + // Concat the /test1/file1 /test1/file2 into /test1/file2 + nnrpc.concat(file2, new String[] {file1}); + inodeCount--; // file1 and file2 are concatenated to file2 + assertEquals(inodeCount, fsn.dir.getInodeMapSize()); + assertEquals(expectedLastInodeId, fsn.getLastInodeId()); + assertTrue(fs.delete(new Path("/test1"), true)); + inodeCount -= 2; // test1 and file2 is deleted + assertEquals(inodeCount, fsn.dir.getInodeMapSize()); - // Make sure empty editlog can be handled + // Make sure editlog is loaded correctly cluster.restartNameNode(); cluster.waitActive(); fsn = cluster.getNamesystem();