From 75b4231a8cf7c7d569111d3014d45585caad99e9 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Fri, 26 Apr 2013 23:47:57 +0000 Subject: [PATCH] HDFS-4761. When resetting FSDirectory, the inodeMap should also be reset. Contributed by Jing Zhao git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1476452 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/server/namenode/FSDirectory.java | 2 ++ .../apache/hadoop/hdfs/server/namenode/TestCheckpoint.java | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e2fd5908cc..c7a8f2e840 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -265,6 +265,9 @@ Trunk (Unreleased) HDFS-4757. Update FSDirectory#inodeMap when replacing an INodeDirectory while setting quota. (Jing Zhao via szetszwo) + HDFS-4761. When resetting FSDirectory, the inodeMap should also be reset. + (Jing Zhao via szetszwo) + BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao, 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 1f1daf935e..8e3a74bb0d 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 @@ -2022,6 +2022,8 @@ void reset() { try { setReady(false); rootDir = createRoot(getFSNamesystem()); + inodeMap.clear(); + addToInodeMapUnprotected(rootDir); nameCache.reset(); } finally { writeUnlock(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java index 3ed98556a5..d84283fa7d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java @@ -77,6 +77,7 @@ import org.apache.hadoop.util.StringUtils; import org.apache.log4j.Level; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatcher; @@ -1061,6 +1062,10 @@ public void testCheckpoint() throws IOException { secondary = startSecondaryNameNode(conf); secondary.doCheckpoint(); + FSDirectory secondaryFsDir = secondary.getFSNamesystem().dir; + INode rootInMap = secondaryFsDir.getInode(secondaryFsDir.rootDir.getId()); + Assert.assertSame(rootInMap, secondaryFsDir.rootDir); + fileSys.delete(tmpDir, true); fileSys.mkdirs(tmpDir); secondary.doCheckpoint();