增加hdfs代码注释

This commit is contained in:
LingZhaoHui 2024-03-27 23:42:27 +08:00
parent 8677cbd3e0
commit 8d242458e9
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC
2 changed files with 9 additions and 2 deletions

View File

@ -151,7 +151,10 @@ private static INodeDirectory createRoot(FSNamesystem namesystem) {
.isdir(true) .isdir(true)
.build(); .build();
// 整个文件系统目录树的根节点 是INodeDirectory类型的
INodeDirectory rootDir; INodeDirectory rootDir;
// Namenode的核心类 这个类主要支持对数据块进行操作的一些方法 例如addBlock()
private final FSNamesystem namesystem; private final FSNamesystem namesystem;
private volatile boolean skipQuotaCheck = false; //skip while consuming edits private volatile boolean skipQuotaCheck = false; //skip while consuming edits
private final int maxComponentLength; private final int maxComponentLength;
@ -159,6 +162,7 @@ private static INodeDirectory createRoot(FSNamesystem namesystem) {
private final int lsLimit; // max list limit private final int lsLimit; // max list limit
private final int contentCountLimit; // max content summary counts per run private final int contentCountLimit; // max content summary counts per run
private final long contentSleepMicroSec; private final long contentSleepMicroSec;
// 记录根目录下所有的INode,并维护INodeId ->INode的映射关系
private final INodeMap inodeMap; // Synchronized by dirLock private final INodeMap inodeMap; // Synchronized by dirLock
private long yieldCount = 0; // keep track of lock yield count. private long yieldCount = 0; // keep track of lock yield count.
private int quotaInitThreads; private int quotaInitThreads;
@ -300,6 +304,7 @@ public int getListLimit() {
/** /**
* Caches frequently used file names used in {@link INode} to reuse * Caches frequently used file names used in {@link INode} to reuse
* byte[] objects and reduce heap usage. * byte[] objects and reduce heap usage.
* 将常用的name缓存下来 以降低byte[]的使用 并降低JVM heap的使用
*/ */
private final NameCache<ByteArray> nameCache; private final NameCache<ByteArray> nameCache;
@ -318,6 +323,7 @@ public enum DirOp {
this.inodeId = new INodeId(); this.inodeId = new INodeId();
rootDir = createRoot(ns); rootDir = createRoot(ns);
inodeMap = INodeMap.newInstance(rootDir); inodeMap = INodeMap.newInstance(rootDir);
// 是否开启权限管理
this.isPermissionEnabled = conf.getBoolean( this.isPermissionEnabled = conf.getBoolean(
DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY, DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY,
DFSConfigKeys.DFS_PERMISSIONS_ENABLED_DEFAULT); DFSConfigKeys.DFS_PERMISSIONS_ENABLED_DEFAULT);

View File

@ -1218,12 +1218,13 @@ private List<AuditLogger> initAuditLoggers(Configuration conf) {
return Collections.unmodifiableList(auditLoggers); return Collections.unmodifiableList(auditLoggers);
} }
// FSNamesystem在初始化完FSDirectory dir成员会调用loadFSImage方法从fsimage和edits加载元数据信息
private void loadFSImage(StartupOption startOpt) throws IOException { private void loadFSImage(StartupOption startOpt) throws IOException {
final FSImage fsImage = getFSImage(); final FSImage fsImage = getFSImage();
// format before starting up if requested // format before starting up if requested // 如果启动选项类型为FORMAT格式化在启动之前需要进行格式化
if (startOpt == StartupOption.FORMAT) { if (startOpt == StartupOption.FORMAT) {
// reuse current id // reuse current id 对FSImage执行格式化操作
fsImage.format(this, fsImage.getStorage().determineClusterId(), false); fsImage.format(this, fsImage.getStorage().determineClusterId(), false);
startOpt = StartupOption.REGULAR; startOpt = StartupOption.REGULAR;