FSDirectory详解:配置和变量 #24

Merged
zeekling merged 5 commits from fsdir into master 2024-04-13 14:10:14 +00:00
Showing only changes of commit fe069fcf71 - Show all commits

View File

@ -74,4 +74,25 @@ boolean delete(String src, boolean recursive, boolean logRetryCache) throws IOEx
**FSDirDeleteOp.delete 实现逻辑** **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信息。