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.
|
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)
|
||||||
|
|
|
@ -647,8 +647,10 @@ public class INodeDirectory extends INodeWithAdditionalFields {
|
||||||
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,
|
||||||
|
|
|
@ -293,11 +293,13 @@ public class INodeFile extends INodeWithAdditionalFields implements BlockCollect
|
||||||
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
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class INodeSymlink extends INodeWithAdditionalFields {
|
||||||
@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
|
||||||
|
|
|
@ -89,16 +89,19 @@ public class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota {
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in New Issue