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 cu...@apache.org on 2006/11/21 00:09:59 UTC
svn commit: r477392 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/dfs/FSDataset.java
Author: cutting
Date: Mon Nov 20 15:09:58 2006
New Revision: 477392
URL: http://svn.apache.org/viewvc?view=rev&rev=477392
Log:
HADOOP-652. In DFS, when a file is deleted, the block count is now decremented. Contributed by Vladimir Krokhmalyov.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=477392&r1=477391&r2=477392
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Mon Nov 20 15:09:58 2006
@@ -88,6 +88,9 @@
26. HADOOP-695. Fix a NullPointerException in contrib/streaming.
(Hairong Kuang via cutting)
+27. HADOOP-652. In DFS, when a file is deleted, the block count is
+ now decremented. (Vladimir Krokhmalyov via cutting)
+
Release 0.8.0 - 2006-11-03
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java?view=diff&rev=477392&r1=477391&r2=477392
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDataset.java Mon Nov 20 15:09:58 2006
@@ -170,6 +170,16 @@
}
}
+ void clearPath(File f) {
+ if (dir.compareTo(f) == 0) numBlocks--;
+ else {
+ if ((siblings != null) && (myIdx != (siblings.length - 1)))
+ siblings[myIdx + 1].clearPath(f);
+ else if (children != null)
+ children[0].clearPath(f);
+ }
+ }
+
public String toString() {
return "FSDir{" +
"dir=" + dir +
@@ -261,6 +271,10 @@
dataDir.getBlockMap(blockMap);
}
+ void clearPath(File f) {
+ dataDir.clearPath(f);
+ }
+
public String toString() {
return dir.getAbsolutePath();
}
@@ -498,15 +512,18 @@
*/
public void invalidate(Block invalidBlks[]) throws IOException {
for (int i = 0; i < invalidBlks.length; i++) {
- synchronized ( this ) {
- File f = getFile(invalidBlks[i]);
- if (!f.delete()) {
- throw new IOException("Unexpected error trying to delete block "
- + invalidBlks[i] + " at file " + f);
- }
+ File f;
+ synchronized (this) {
+ f = getFile(invalidBlks[i]);
+ FSVolume v = volumeMap.get(invalidBlks[i]);
+ v.clearPath(f.getParentFile());
blockMap.remove(invalidBlks[i]);
volumeMap.remove(invalidBlks[i]);
- }
+ }
+ if (!f.delete()) {
+ throw new IOException("Unexpected error trying to delete block "
+ + invalidBlks[i] + " at file " + f);
+ }
DataNode.LOG.info("Deleting block " + invalidBlks[i]);
}
}