你好,游客 登录 注册 搜索
背景:
阅读新闻

Hadoop分析之三org.apache.hadoop.hdfs.server.namenode各个类的功能与角色

[日期:2012-07-24] 来源:blog.csdn.net/kntao  作者:kntao [字体:大 中 小]
以Hadoop0.21为例。
NameNode.java: 主要维护文件系统的名字空间和文件的元数据,以下是代码中的说明。
  1. /********************************************************** 
  2.  * NameNode serves as both directory namespace manager and 
  3.  * "inode table" for the Hadoop DFS.  There is a single NameNode 
  4.  * running in any DFS deployment.  (Well, except when there 
  5.  * is a second backup/failover NameNode.) 
  6.  * 
  7.  * The NameNode controls two critical tables: 
  8.  *   1)  filename ->blocksequence (namespace) 
  9.  *   2)  block ->machinelist ("inodes") 
  10.  * 
  11.  * The first table is stored on disk and is very precious. 
  12.  * The second table is rebuilt every time the NameNode comes 
  13.  * up. 
  14.  * 
  15.  * 'NameNode' refers to both this class as well as the 'NameNode server'. 
  16.  * The 'FSNamesystem' class actually performs most of the filesystem 
  17.  * management.  The majority of the 'NameNode' class itself is concerned 
  18.  * with exposing the IPC interface and the http server to the outside world, 
  19.  * plus some configuration management. 
  20.  * 
  21.  * NameNode implements the ClientProtocol interface, which allows 
  22.  * clients to ask for DFS services.  ClientProtocol is not 
  23.  * designed for direct use by authors of DFS client code.  End -users 
  24.  * should instead use the org.apache.nutch.hadoop.fs.FileSystem class. 
  25.  * 
  26.  * NameNode also implements the DatanodeProtocol interface, used by 
  27.  * DataNode programs that actually store DFS data blocks.  These 
  28.  * methods are invoked repeatedly and automatically by all the 
  29.  * DataNodes in a DFS deployment. 
  30.  * 
  31.  * NameNode also implements the NamenodeProtocol interface, used by 
  32.  * secondary namenodes or rebalancing processes to get partial namenode's 
  33.  * state, for example partial blocksMap etc. 
  34.  **********************************************************/  
FSNamesystem.java: 主要维护几个表的信息:维护了文件名与block列表的映射关系;有效的block的集合;block与节点列表的映射关系;节点与block列表的映射关系;更新的heatbeat节点的LRU cache
  1. /*************************************************** 
  2.  * FSNamesystem does the actual bookkeeping work for the 
  3.  * DataNode. 
  4.  * 
  5.  * It tracks several important tables. 
  6.  * 
  7.  * 1)  valid fsname --> blocklist  (kept on disk, logged) 
  8.  * 2)  Set of all valid blocks (inverted #1) 
  9.  * 3)  block --> machinelist (kept in memory, rebuilt dynamically from reports) 
  10.  * 4)  machine --> blocklist (inverted #2) 
  11.  * 5)  LRU cache of updated -heartbeat machines 
  12.  ***************************************************/  
INode.java:HDFS将文件和文件目录抽象成INode。
  1. /** 
  2.  * We keep an in-memory representation of the file/block hierarchy. 
  3.  * This is a base INode class containing common fields for file and 
  4.  * directory inodes. 
  5.  */  
FSImage.java:需要将INode信息持久化到磁盘上FSImage上。
  1. /** 
  2.  * FSImage handles checkpointing and logging of the namespace edits. 
  3.  * 
  4.  */  
FSEditLog.java:写Edits文件
  1. /** 
  2.  * FSEditLog maintains a log of the namespace modifications. 
  3.  * 
  4.  */  
linux
相关资讯       Hadoop应用 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款