Hbase0.96源码之HMaster(三)Hmaster主要循环
1。Master初始化
1.1
if (!this.stopped) {
finishInitialization(startupStatus, false);
loop();
}
1.2 finishInitialization()。这里主要完毕master组件components:filesystem manager,servermanager,assignmentmanager,regionservertracker, catalogtracker等
1.2.1 设置为active master
isActiveMaster = true;
1.2.2 生成MasterFileSystem(fileSystemManager),管理一些文件系统的操作,包括deleteregion,deletetable,modifyColumn,addColumn,deleteFamilyFromFS以及splitlog,splitMetaLog等
1.2.2.1 check rootdir以及temp文件夹都存在。且清除temp文件夹
this.oldLogDir = createInitialFileSystemLayout();
1.2.2.1.1clean tempdir
// check if the root directory exists
checkRootDir(this.rootdir, conf, this.fs);
// check if temp directory exists and clean it
checkTempDir(this.tempdir, conf, this.fs);
1.2.2.1.2在checkRootDir()中检測meta的
// Make sure the meta region directory exists!
if (!FSUtils.metaRegionExists(fs, rd)) {
bootstrap(rd, c);
} else {
// Migrate table descriptor files if necessary
org.apache.hadoop.hbase.util.FSTableDescriptorMigrationToSubdir
.migrateFSTableDescriptorsIfNecessary(fs, rd);
}
1.2.2.1.2.1 假设meta数据文件夹不存在。创建meta?
private static void bootstrap(final Path rd, final Configuration c)
throws IOException {
LOG.info("BOOTSTRAP: creating hbase:meta region");
try {
// Bootstrapping, make sure blockcache is off. Else, one will be
// created here in bootstrap and it'll need to be cleaned up. Better to
// not make it in first place. Turn off block caching for bootstrap.
// Enable after.
HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
setInfoFamilyCachingForMeta(false);
HRegion meta = HRegion.createHRegion(metaHRI, rd, c,
HTableDescriptor.META_TABLEDESC);
setInfoFamilyCachingForMeta(true);
HRegion.closeHRegion(meta);
} catch (IOException e) {
e = RemoteExceptionHandler.checkIOException(e);
LOG.error("bootstrap", e);
throw e;
}
}
1.2.2.2 splitLogManager的创建
this.splitLogManager = new SplitLogManager(master.getZooKeeper(),
master.getConfiguration(), master, services,
master.getServerName(), masterRecovery);
1.2.3 创建executorService与serverManager,当中executorService维护一个ExecutorMap,EventType与Executor。提交不正确应的EventHandler来异步处理事件;serverManager管理regionserver
if (!masterRecovery) {
this.executorService = new ExecutorService(getServerName().toShortString());
this.serverManager = createServerManager(this, this);
}
1.2.4 initializeZKBasedSystemTrackers
1.2.4.1 create CatalogTracker 监听-ROOT-和.META.的Server地址信息变化以及事件处理
1.2.4.2 LoadBalancerTracker
1.2.4.3 AssignmentManager管理和分配region,监听zk上关于region的event,依据event来完毕region的上下线
1.2.4.4 RegionServerTracker watch zk中中regionSerrver的变化及事件处理。下线
1.2.4.5 DrainingServerTracker
1.2.4.6 SnapshotManager Snapshot快照管理祥光
void initializeZKBasedSystemTrackers() throws IOException,
InterruptedException, KeeperException {
this.catalogTracker = createCatalogTracker(this.zooKeeper, this.conf, this);
this.catalogTracker.start();
this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
this.loadBalancerTracker = new LoadBalancerTracker(zooKeeper, this);
this.loadBalancerTracker.start();
this.assignmentManager = new AssignmentManager(this, serverManager,
this.catalogTracker, this.balancer, this.executorService, this.metricsMaster,
this.tableLockManager);
zooKeeper.registerListenerFirst(assignmentManager);
this.regionServerTracker = new RegionServerTracker(zooKeeper, this,
this.serverManager);
this.regionServerTracker.start();
this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this,
this.serverManager);
this.drainingServerTracker.start();
// Set the cluster as up. If new RSs, they'll be waiting on this before
// going ahead with their startup.
boolean wasUp = this.clusterStatusTracker.isClusterUp();
if (!wasUp) this.clusterStatusTracker.setClusterUp();
LOG.info("Server active/primary master=" + this.serverName +
", sessionid=0x" +
Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()) +
", setting cluster-up flag (Was=" + wasUp + ")");
// create the snapshot manager
this.snapshotManager = new SnapshotManager(this, this.metricsMaster);
}Hbase0.96源码之HMaster(三)Hmaster主要循环的更多相关文章
- Hbase0.96源码之HMaster(一)
从main()函数開始 public static void main(String [] args) { VersionInfo.logVersion(); new HMasterCommandLi ...
- Hbase0.96源码之HMaster(二)Hmaster主要循环becomeActiveMaster
1,Hmaster主循环主要这里主要有: 1,1 becomeActiveMaster(startupStatus); 1.2 finishInitialization 1.3 loop() beco ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 【原】AFNetworking源码阅读(三)
[原]AFNetworking源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇的话,主要是讲了如何通过构建一个request来生成一个data tas ...
- 【原】SDWebImage源码阅读(三)
[原]SDWebImage源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1.SDWebImageDownloader中的downloadImageWithURL 我们 ...
- Cwinux源码解析(三)
我在我的 薛途的博客 上发表了新的文章,欢迎各位批评指正. Cwinux源码解析(三)
- 一个普通的 Zepto 源码分析(三) - event 模块
一个普通的 Zepto 源码分析(三) - event 模块 普通的路人,普通地瞧.分析时使用的是目前最新 1.2.0 版本. Zepto 可以由许多模块组成,默认包含的模块有 zepto 核心模块, ...
- vueJs 源码解析 (三) 具体代码
vueJs 源码解析 (三) 具体代码 在之前的文章中提到了 vuejs 源码中的 架构部分,以及 谈论到了 vue 源码三要素 vm.compiler.watcher 这三要素,那么今天我们就从这三 ...
- Android源码浅析(三)——Android AOSP 5.1.1源码的同步sync和编译make,搭建Samba服务器进行更便捷的烧录刷机
Android源码浅析(三)--Android AOSP 5.1.1源码的同步sync和编译make,搭建Samba服务器进行更便捷的烧录刷机 最近比较忙,而且又要维护自己的博客,视频和公众号,也就没 ...
随机推荐
- 泛型(二)封装工具类CommonUtils-把一个Map转换成指定类型的javabean对象
1.commons-beanutils的使用 commons-beanutils-1.9.3.jar 依赖 commons-logging-1.2.jar 代码1: String className ...
- jquery lt选择器 语法
jquery lt选择器 语法 作用::lt 选择器选取带有小于指定 index 值的元素.index 值从 0 开始.经常与其他元素/选择器一起使用,来选择指定的组中特定序号之前的元素(如上面的例子 ...
- MySQL_约束
MySQL中约束的作用是对表中的数据进行限定,保证数据的正确性,完整性,有效性. 分类:(1)主键约束 primary key(2)非空约束 not NULL (3)唯一约束 unique (4)外键 ...
- (50)LINUX应用编程和网络编程之五 Linux信号(进程间通信)
信号实现进程间的通信 3.5.1.什么是信号 ...
- BZOJ 4422 Cow Confinement (线段树、DP、扫描线、差分)
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=4422 我真服了..这题我能调一天半,最后还是对拍拍出来的...脑子还是有病啊 题解: ...
- 如何下载如腾讯课堂等PC网页视频的方法
其实网上的教程有很多,实际也没那么复杂. 一.用插件法 方法是用插件,大多数主流的浏览器都是支持插件的,只要下载个插件应用市场的视频插件就可以搞定了. 当然,每个浏览器的视频插件品牌都是不一样的.这里 ...
- 聊聊spring-boot-starter-data-redis的配置变更
本文主要研究一下spring-boot-starter-data-redis的配置变更 配置变更 以前是spring-boot的1.4.x版本的(spring-data-redis为1.7.x版本), ...
- js,正则实现金钱格式化
https://blog.csdn.net/qq_36279445/article/details/78889305 https://github.com/jawil/blog/issues/30
- centos7 升级gcc9.1.0版本
centos7 环境 查缺补漏 yum install gcc gcc-c++ -y yum install bzip2 -y gcc版本下载:https://gcc.gnu.org/mirrors. ...
- post与get方法的区别
1. GET请求:请求的数据会附加在URL之后,以?分割URL和传输数据,多个参数用&连接.URL的编码格式采用的是ASCII编码,而不是unicode,即是说所有的非ASCII字符都要编码之 ...