FSDirectory详解:配置和变量
This commit is contained in:
parent
b83b0dcf04
commit
fe069fcf71
@ -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信息。
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user