HDFS1.0源代码解析—DataNode状态切换
2012-05-11 09:40
309 查看
Hadoop支持软件升级,对于Hadoop这样一个分布式的系统,升级将是一件很复杂的事情。下面介绍升级过程中DataNode的状态切换
首先来看DataNode可能存在的各种状态:
该图摘在别人博客(感觉画的很透彻)
上图描述了各状态之间的切换流程。
1、DataNoe的具体升级流程如下:见DataStorage.java的doUpgrade方法
获取当前的current和previous目录,如果previous目录存在先删除,将当前current目录重命名为previous.tmp,建立current到previous.tmp的硬链接,在current里写入新的VERSION文件,将previous.tmp改名为previous,完成升级。其实整个升级的过程只是对VERSION文件的改写,对原先的数据文件只是建立了硬链接。
2、DataNode的回滚流程:
首先来看DataNode可能存在的各种状态:
FORMAT ("-format"),//格式化,用于系统第一次启动,必须先进行格式 REGULAR ("-regular"),//用于正常启动 UPGRADE ("-upgrade"),//进行升级的命令 ROLLBACK("-rollback"),//升级过程中出现错误,进行回滚 FINALIZE("-finalize"),//升级稳定后,进行提交 IMPORT ("-importCheckpoint");//将系统恢复到某个checkpoint
该图摘在别人博客(感觉画的很透彻)
上图描述了各状态之间的切换流程。
1、DataNoe的具体升级流程如下:见DataStorage.java的doUpgrade方法
File curDir = sd.getCurrentDir(); File prevDir = sd.getPreviousDir(); assert curDir.exists() : "Current directory must exist."; // delete previous dir before upgrading if (prevDir.exists()) deleteDir(prevDir); File tmpDir = sd.getPreviousTmp();//获取previous.tmp assert !tmpDir.exists() : "previous.tmp directory must not exist."; // rename current to tmp rename(curDir, tmpDir);//将当前的current目录,重命名为previous.tmp // hardlink blocks linkBlocks(tmpDir, curDir, this.getLayoutVersion(), hardLink); // write version file this.layoutVersion = FSConstants.LAYOUT_VERSION; assert this.namespaceID == nsInfo.getNamespaceID() : "Data-node and name-node layout versions must be the same."; this.cTime = nsInfo.getCTime(); sd.write(); // rename tmp to previous rename(tmpDir, prevDir);
获取当前的current和previous目录,如果previous目录存在先删除,将当前current目录重命名为previous.tmp,建立current到previous.tmp的硬链接,在current里写入新的VERSION文件,将previous.tmp改名为previous,完成升级。其实整个升级的过程只是对VERSION文件的改写,对原先的数据文件只是建立了硬链接。
2、DataNode的回滚流程:
相关文章推荐
- HDFS1.0源代码解析—DataNode启动(三)
- HDFS1.0源代码解析—DataNode启动(二)
- HDFS1.0源代码解析—DataNode数据接收线程DataXceiverServer与DataXceiver解析
- HDFS1.0源代码解析—DataNode启动(一)
- hdfs haadmin使用,DataNode动态上下线,NameNode状态切换管理,数据块的balance,HA下hdfs-api变化(来自学习资料)
- HDFS1.0源代码解析—DataNode端数据存储和管理DataStorage和FSDataset解析
- HDFS1.0源代码解析—DataNode类主要数据成员和函数
- HDFS DataNode 设计实现解析
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- 关于DataNode更改IP地址后所可能引发HDFS集群状态变化的分析
- HDFS DataNode 设计实现解析
- hadoop-HA集群搭建,启动DataNode,检测启动状态,执行HDFS命令,启动YARN,HDFS权限配置,C++客户端编程,常见错误
- HDFS1.0源代码解析—Hadoop的RPC机制之Server端解析
- HDFS的create函数解析及如何选择存储Block的DataNode
- HDFS1.0源代码解析—Hadoop的RPC机制之Client解析
- 大数据之路-Hadoop-5-HDFS原理解析及NameNode、DataNode工作机制
- HDFS1.0源代码解析—数据传输和接受的类BlockSender和BlockReceiver
- hadoop源代码分析(1)-hdfs.server.datanode包-DataNode类【原创】