You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ra...@apache.org on 2008/05/21 22:51:50 UTC
svn commit: r658862 - in /hadoop/core/trunk: CHANGES.txt
src/java/org/apache/hadoop/dfs/FSDirectory.java
src/java/org/apache/hadoop/dfs/INode.java
Author: rangadi
Date: Wed May 21 13:51:49 2008
New Revision: 658862
URL: http://svn.apache.org/viewvc?rev=658862&view=rev
Log:
HADOOP-3381. Clear referenced when directories are deleted so that
effect of memory leaks are not multiplied. (rangadi)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
hadoop/core/trunk/src/java/org/apache/hadoop/dfs/INode.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=658862&r1=658861&r2=658862&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed May 21 13:51:49 2008
@@ -149,6 +149,9 @@
HADOOP-3398. Minor improvement to a utility function in that participates
in backoff calculation. (cdouglas)
+ HADOOP-3381. Clear referenced when directories are deleted so that
+ effect of memory leaks are not multiplied. (rangadi)
+
OPTIMIZATIONS
HADOOP-3274. The default constructor of BytesWritable creates empty
Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java?rev=658862&r1=658861&r2=658862&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java Wed May 21 13:51:49 2008
@@ -534,16 +534,17 @@
// Remove the node from the namespace and GC all
// the blocks underneath the node.
//
- if (!targetNode.removeNode()) {
+ if (targetNode.getParent() == null) {
NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedDelete: "
+"failed to remove "+src+" because it does not have a parent");
return null;
} else {
+ targetNode.getParent().setModificationTime(modificationTime);
+ targetNode.removeNode();
NameNode.stateChangeLog.debug("DIR* FSDirectory.unprotectedDelete: "
+src+" is removed");
- targetNode.getParent().setModificationTime(modificationTime);
ArrayList<Block> v = new ArrayList<Block>();
- int filesRemoved = targetNode.collectSubtreeBlocks(v);
+ int filesRemoved = targetNode.collectSubtreeBlocksAndClear(v);
incrDeletedFileCount(filesRemoved);
totalInodes -= filesRemoved;
for (Block b : v) {
Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/INode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/INode.java?rev=658862&r1=658861&r2=658862&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/INode.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/INode.java Wed May 21 13:51:49 2008
@@ -144,7 +144,12 @@
* Check whether it's a directory
*/
abstract boolean isDirectory();
- abstract int collectSubtreeBlocks(List<Block> v);
+ /**
+ * Collect all the blocks in all children of this INode.
+ * Count and return the number of files in the sub tree.
+ * Also clears references since this INode is deleted.
+ */
+ abstract int collectSubtreeBlocksAndClear(List<Block> v);
/** Compute {@link ContentSummary}. */
final ContentSummary computeContentSummary() {
@@ -264,6 +269,7 @@
} else {
parent.removeChild(this);
+ parent = null;
return true;
}
}
@@ -612,18 +618,16 @@
return children;
}
- /**
- * Collect all the blocks in all children of this INode.
- * Count and return the number of files in the sub tree.
- */
- int collectSubtreeBlocks(List<Block> v) {
+ int collectSubtreeBlocksAndClear(List<Block> v) {
int total = 1;
if (children == null) {
return total;
}
for (INode child : children) {
- total += child.collectSubtreeBlocks(v);
+ total += child.collectSubtreeBlocksAndClear(v);
}
+ parent = null;
+ children = null;
return total;
}
}
@@ -736,14 +740,12 @@
this.blocks[idx] = blk;
}
- /**
- * Collect all the blocks in this INode.
- * Return the number of files in the sub tree.
- */
- int collectSubtreeBlocks(List<Block> v) {
+ int collectSubtreeBlocksAndClear(List<Block> v) {
+ parent = null;
for (Block blk : blocks) {
v.add(blk);
}
+ blocks = null;
return 1;
}