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

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

[日期:2012-07-24] 来源:blog.csdn.net/kntao  作者:kntao [字体:大 中 小]
BlockInfo.java:INode主要是所文件和目录信息的,而对于文件的内容来说,这是用block描述的。我们假设一个文件的长度大小为Size,那么从文件的0偏移开始,按照固定大小,顺序对文件划分并编号,划分好的每一块为一个block
  1. /** 
  2.  * Internal class for block metadata. 
  3.  */  
DatanodeDescriptor.java:代表的具体的存储对象。
  1. /************************************************** 
  2.  * DatanodeDescriptor tracks stats on a given DataNode, 
  3.  * such as available storage capacity, last update time, etc., 
  4.  * and maintains a set of blocks stored on the datanode. 
  5.  * 
  6.  * This data structure is a data structure that is internal 
  7.  * to the namenode. It is *not* sent over- the- wire to the Client 
  8.  * or the Datnodes. Neither is it stored persistently in the 
  9.  * fsImage. 
  10.  
  11.  **************************************************/  
FSDirectory.java: 代表了HDFS中的所有目录和结构属性
  1. /************************************************* 
  2.  * FSDirectory stores the filesystem directory state. 
  3.  * It handles writing/loading values to disk, and logging 
  4.  * changes as we go. 
  5.  * 
  6.  * It keeps the filename->blockset mapping always- current 
  7.  * and logged to disk. 
  8.  * 
  9.  *************************************************/  
EditLogOutputStream.java:所有的日志记录都是通过EditLogOutputStream输出,在具体实例化的时候,这一组EditLogOutputStream包含多个EditLogFIleOutputStream和一个EditLogBackupOutputStream
  1. /** 
  2.  * A generic abstract class to support journaling of edits logs into 
  3.  * a persistent storage. 
  4.  */  
EditLogFileOutputStream.java:将日志记录写到edits或edits.new中。
  1. /** 
  2.  * An implementation of the abstract class {@link EditLogOutputStream}, which 
  3.  * stores edits in a local file. 
  4.  */  
EditLogBackupOutputStream.java:将日志通过网络发送到backupnode上。
  1. /** 
  2.  * An implementation of the abstract class {@link EditLogOutputStream}, 
  3.  * which streams edits to a backup node. 
  4.  * 
  5.  * @see org.apache.Hadoop.hdfs.server.protocol.NamenodeProtocol#journal 
  6.  * (org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration, 
  7.  *  int, int, byte[]) 
  8.  */  
BackupNode.java:name Node的backup:升级阶段:Secondary Name Node -》Checkpoint Node(定期保存元数据,定期checkpoint) -》Backup Node(在内存中保持一份和Name Node完全一致的镜像,当元数据发生变化时,其元数据进行更新,可以利用自身的镜像来checkpoint,无需从nameNode下载)-》Standby Node(可以进行热备)
  1. /** 
  2.  * BackupNode. 
  3.  * <p> 
  4.  * Backup node can play two roles. 
  5.  * <ol> 
  6.  * <li>{@link NamenodeRole#CHECKPOINT} node periodically creates checkpoints, 
  7.  * that is downloads image and edits from the active node, merges them, and 
  8.  * uploads the new image back to the active. </li> 
  9.  * <li>{@link NamenodeRole#BACKUP} node keeps its namespace in sync with the 
  10.  * active node, and periodically creates checkpoints by simply saving the 
  11.  * namespace image to local disk(s).</li> 
  12.  * </ol> 
  13.  */  
BackupStorage.java:在Backup Node备份目录下创建jspool,并创建edits.new,将输出流指向edits.new
  1. /** 
  2.  * Load checkpoint from local files only if the memory state is empty.<br> 
  3.  * Set new checkpoint time received from the name -node. <br> 
  4.  * Move <code>lastcheckpoint.tmp </code> to <code>previous.checkpoint</code> . 
  5.  * @throws IOException 
  6.  */  
TransferFsImage.java:负责从name Node去文件。
  1. /** 
  2.  * This class provides fetching a specified file from the NameNode. 
  3.  */  

GetImageServlet.java:是httpServlet的子类,处理doGet请求。

  1. /** 
  2.  * This class is used in Namesystem's jetty to retrieve a file. 
  3.  * Typically used by the Secondary NameNode to retrieve image and 
  4.  * edit file for periodic checkpointing. 
  5.  */  
linux
相关资讯       Hadoop应用 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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