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:
parent
9701555899
commit
ca7c588185
@ -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)
|
||||
|
@ -647,8 +647,10 @@ public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
|
||||
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,
|
||||
|
@ -293,11 +293,13 @@ public void setBlocks(BlockInfo[] blocks) {
|
||||
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
|
||||
|
@ -74,7 +74,7 @@ public byte[] getSymlink() {
|
||||
@Override
|
||||
public Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
|
||||
final BlocksMapUpdateInfo collectedBlocks) {
|
||||
return Quota.Counts.newInstance();
|
||||
return Quota.Counts.newInstance(1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,16 +89,19 @@ private final boolean removeCreatedChild(final int c, final INode child) {
|
||||
}
|
||||
|
||||
/** 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 Quota.Counts cleanSubtree(final Snapshot snapshot, Snapshot prior,
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user