【HDFS】什么叫块恢复

从租约管理注释,看写入一致性的一种基本算法

**

 * LeaseManager does the lease housekeeping for writing on files.   
 * This class also provides useful static methods for lease recovery.
 * 租约管理器主要目的是为了写一致性
 * Lease Recovery Algorithm      租约恢复算法
 * 1) Namenode retrieves lease information  namenode获得租约信息
 * 2) For each file f in the lease, consider the last block b of f    一个租约可能是为了写多个文件向fsnamesystem申请的
 * 对于每一个文件的最后一个块,考虑以下几种问题

 * 2.1) Get the datanodes which contains b知道最后一个块在哪些datanode上
 * 2.2) Assign one of the datanodes as the primary datanode p
        在拥有最后一个块的dn中选主
 * 2.3) p obtains a new generation stamp form the namenode  这个主dn跟namenode要最新的块时间戳,目的是找到哪个dn的最后一个块是更后更新的
 * 2.4) p get the block info from each datanode  主dn要掌握其余有最后一个块的dn的关于这个块的信息,为啥是最后一个块?
 *

 * 因为最后一个块往往有可能因为写的时候出现不一致的情况,有的写得差不多,有的可能还没写完。
 * 2.5) p computes the minimum block length 主dn根据掌握的其它dn上这最后一个块的情况,找到目前已经写了的最小长度
 * 2.6) p updates the datanodes, which have a valid generation stamp,
 *      with the new generation stamp and the minimum block length
 *      主dn,找到那个最后向nn汇报的dn,并且它的块长度是最短的,这个块应该是最准确的
 * 2.7) p acknowledges the namenode the update results
    主机告诉nn,上面的结果
 * 2.8) Namenode updates the BlockInfo nn更新关于这个块的元信息
 * 2.9) Namenode removes f from the lease  把这个文件从租约里剔除,没有了租约,就没法写了,如果这个租约不对应任何文件,连这个租约一起干掉
 *      and removes the lease once all files have been removed
 * 2.10) Namenode commit changes to edit log  nn写editslog,这也是改变元数据的一部分
 *
 * 从上面的块恢复可以看出来,所谓块恢复是在写块的时候,为了保证一致性,找到最后一个块的基准块的过程,那些写得可能比较多的块就会被删除

 */

未完,待续。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值