HDFS-4616. Update the FilesDeleted metric while deleting file/dir in the current tree. Contributed by Jing Zhao

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1459485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-03-21 19:30:35 +00:00
parent 9701555899
commit ca7c588185
5 changed files with 15 additions and 5 deletions

View File

@ -204,3 +204,6 @@ Branch-2802 Snapshot (Unreleased)
HDFS-4534. Add INodeReference in order to support rename with snapshots.
(szetszwo)
HDFS-4616. Update the FilesDeleted metric while deleting file/dir in the
current tree. (Jing Zhao via szetszwo)

View File

@ -647,8 +647,10 @@ public class INodeDirectory extends INodeWithAdditionalFields {
throws QuotaExceededException {
if (prior == null && snapshot == null) {
// destroy the whole subtree and collect blocks that should be deleted
Quota.Counts counts = Quota.Counts.newInstance();
this.computeQuotaUsage(counts, true);
destroyAndCollectBlocks(collectedBlocks);
return Quota.Counts.newInstance();
return counts;
} else {
// process recursively down the subtree
Quota.Counts counts = cleanSubtreeRecursively(snapshot, prior,

View File

@ -293,11 +293,13 @@ public class INodeFile extends INodeWithAdditionalFields implements BlockCollect
public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
final BlocksMapUpdateInfo collectedBlocks)
throws QuotaExceededException {
Quota.Counts counts = Quota.Counts.newInstance();
if (snapshot == null && prior == null) {
// this only happens when deleting the current file
computeQuotaUsage(counts, false);
destroyAndCollectBlocks(collectedBlocks);
}
return Quota.Counts.newInstance();
return counts;
}
@Override

View File

@ -74,7 +74,7 @@ public class INodeSymlink extends INodeWithAdditionalFields {
@Override
public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
final BlocksMapUpdateInfo collectedBlocks) {
return Quota.Counts.newInstance();
return Quota.Counts.newInstance(1, 0);
}
@Override

View File

@ -89,16 +89,19 @@ public class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota {
}
/** clear the created list */
private void destroyCreatedList(
private Quota.Counts destroyCreatedList(
final INodeDirectoryWithSnapshot currentINode,
final BlocksMapUpdateInfo collectedBlocks) {
Quota.Counts counts = Quota.Counts.newInstance();
final List<INode> createdList = getList(ListType.CREATED);
for (INode c : createdList) {
c.computeQuotaUsage(counts, true);
c.destroyAndCollectBlocks(collectedBlocks);
// c should be contained in the children list, remove it
currentINode.removeChild(c);
}
createdList.clear();
return counts;
}
/** clear the deleted list */
@ -659,7 +662,7 @@ public class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota {
// delete everything in created list
DirectoryDiff lastDiff = diffs.getLast();
if (lastDiff != null) {
lastDiff.diff.destroyCreatedList(this, collectedBlocks);
counts.add(lastDiff.diff.destroyCreatedList(this, collectedBlocks));
}
} else {
// update prior