FSDirectory详解:配置和变量

This commit is contained in:
LingZhaoHui 2024-04-13 22:08:29 +08:00
parent b83b0dcf04
commit fe069fcf71
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC
1 changed files with 21 additions and 0 deletions

View File

@ -74,4 +74,25 @@ boolean delete(String src, boolean recursive, boolean logRetryCache) throws IOEx
**FSDirDeleteOp.delete 实现逻辑**
- 检查权限调用FSDirectory的函数checkPermission检查权限。
- 如果是非空的文件夹,检查是否有-r参数。如果没有-r参数则需要报错。
- 调用deleteInternal开始删除文件夹。核心删除代码如下
```java
List<INodeDirectory> snapshottableDirs = new ArrayList<>();
FSDirSnapshotOp.checkSnapshot(fsd, iip, snapshottableDirs);
ReclaimContext context = new ReclaimContext(
fsd.getBlockStoragePolicySuite(), collectedBlocks, removedINodes,
removedUCFiles);
// 更核心的删除代码再这个函数里面会调用destroyAndCollectBlocks删除block,代码targetNode.destroyAndCollectBlocks(reclaimContext);
if (unprotectedDelete(fsd, iip, context, mtime)) {
filesRemoved = context.quotaDelta().getNsDelta();
fsn.removeSnapshottableDirs(snapshottableDirs);
}
fsd.updateReplicationFactor(context.collectedBlocks()
.toUpdateReplicationInfo());
fsd.updateCount(iip, context.quotaDelta(), false);
```
- 删除EditLog。
- 调用incrDeletedFileCount更新metrics信息。