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. HDFS-4534. Add INodeReference in order to support rename with snapshots.
(szetszwo) (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 Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
throws QuotaExceededException { throws QuotaExceededException {
if (prior == null && snapshot == null) { if (prior == null && snapshot == null) {
// destroy the whole subtree and collect blocks that should be deleted // destroy the whole subtree and collect blocks that should be deleted
Quota.Counts counts = Quota.Counts.newInstance();
this.computeQuotaUsage(counts, true);
destroyAndCollectBlocks(collectedBlocks); destroyAndCollectBlocks(collectedBlocks);
return Quota.Counts.newInstance(); return counts;
} else { } else {
// process recursively down the subtree // process recursively down the subtree
Quota.Counts counts = cleanSubtreeRecursively(snapshot, prior, Quota.Counts counts = cleanSubtreeRecursively(snapshot, prior,

View File

@ -293,11 +293,13 @@ public void setBlocks(BlockInfo[] blocks) {
public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior, public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
final BlocksMapUpdateInfo collectedBlocks) final BlocksMapUpdateInfo collectedBlocks)
throws QuotaExceededException { throws QuotaExceededException {
Quota.Counts counts = Quota.Counts.newInstance();
if (snapshot == null && prior == null) { if (snapshot == null && prior == null) {
// this only happens when deleting the current file // this only happens when deleting the current file
computeQuotaUsage(counts, false);
destroyAndCollectBlocks(collectedBlocks); destroyAndCollectBlocks(collectedBlocks);
} }
return Quota.Counts.newInstance(); return counts;
} }
@Override @Override

View File

@ -74,7 +74,7 @@ public byte[] getSymlink() {
@Override @Override
public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior, public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
final BlocksMapUpdateInfo collectedBlocks) { final BlocksMapUpdateInfo collectedBlocks) {
return Quota.Counts.newInstance(); return Quota.Counts.newInstance(1, 0);
} }
@Override @Override

View File

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