You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by sz...@apache.org on 2013/04/26 02:50:10 UTC
svn commit: r1476005 - in
/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt
src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
Author: szetszwo
Date: Fri Apr 26 00:50:09 2013
New Revision: 1476005
URL: http://svn.apache.org/r1476005
Log:
HDFS-4757. Update FSDirectory#inodeMap when replacing an INodeDirectory while setting quota. Contributed by Jing Zhao
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1476005&r1=1476004&r2=1476005&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Apr 26 00:50:09 2013
@@ -259,6 +259,9 @@ Trunk (Unreleased)
failure to unpack old image tarball that contains hard links.
(Chris Nauroth via szetszwo)
+ HDFS-4757. Update FSDirectory#inodeMap when replacing an INodeDirectory
+ while setting quota. (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,
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=1476005&r1=1476004&r2=1476005&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Fri Apr 26 00:50:09 2013
@@ -1793,7 +1793,6 @@ public class FSDirectory implements Clos
}
dir.clearChildren();
}
-
/** Update the count of each directory with quota in the namespace
* A directory's count is defined as the total number inodes in the tree
@@ -1923,6 +1922,8 @@ public class FSDirectory implements Clos
INodeDirectory parent = (INodeDirectory)inodes[inodes.length-2];
dirNode = newNode;
parent.replaceChild(newNode);
+ // update the inodeMap
+ inodeMap.put(newNode);
}
} else {
// a non-quota directory; so replace it with a directory with quota
@@ -1932,6 +1933,8 @@ public class FSDirectory implements Clos
INodeDirectory parent = (INodeDirectory)inodes[inodes.length-2];
dirNode = newNode;
parent.replaceChild(newNode);
+ // update the inodeMap
+ inodeMap.put(newNode);
}
return (oldNsQuota != nsQuota || oldDsQuota != dsQuota) ? dirNode : null;
}
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java?rev=1476005&r1=1476004&r2=1476005&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java Fri Apr 26 00:50:09 2013
@@ -19,8 +19,9 @@
package org.apache.hadoop.hdfs.server.namenode;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
@@ -890,4 +891,39 @@ public class TestINodeFile {
resolvedPath = FSDirectory.resolvePath(testPath, components, fsd);
assertEquals(testPath, resolvedPath);
}
+
+ /**
+ * Test whether the inode in inodeMap has been replaced after regular inode
+ * replacement
+ */
+ @Test
+ public void testInodeReplacement() throws Exception {
+ final Configuration conf = new Configuration();
+ final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).
+ numDataNodes(1).build();
+ cluster.waitActive();
+ final DistributedFileSystem hdfs = cluster.getFileSystem();
+ final FSDirectory fsdir = cluster.getNamesystem().getFSDirectory();
+
+ final Path dir = new Path("/dir");
+ hdfs.mkdirs(dir);
+ INode dirNode = fsdir.getINode(dir.toString());
+ INode dirNodeFromNode = fsdir.getInode(dirNode.getId());
+ assertSame(dirNode, dirNodeFromNode);
+
+ // set quota to dir, which leads to node replacement
+ hdfs.setQuota(dir, Long.MAX_VALUE - 1, Long.MAX_VALUE - 1);
+ dirNode = fsdir.getINode(dir.toString());
+ assertTrue(dirNode instanceof INodeDirectoryWithQuota);
+ // the inode in inodeMap should also be replaced
+ dirNodeFromNode = fsdir.getInode(dirNode.getId());
+ assertSame(dirNode, dirNodeFromNode);
+
+ hdfs.setQuota(dir, -1, -1);
+ dirNode = fsdir.getINode(dir.toString());
+ assertTrue(dirNode instanceof INodeDirectory);
+ // the inode in inodeMap should also be replaced
+ dirNodeFromNode = fsdir.getInode(dirNode.getId());
+ assertSame(dirNode, dirNodeFromNode);
+ }
}