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主要循环的更多相关文章

  1. Hbase0.96源码之HMaster(一)

    从main()函数開始 public static void main(String [] args) { VersionInfo.logVersion(); new HMasterCommandLi ...

  2. Hbase0.96源码之HMaster(二)Hmaster主要循环becomeActiveMaster

    1,Hmaster主循环主要这里主要有: 1,1 becomeActiveMaster(startupStatus); 1.2 finishInitialization 1.3 loop() beco ...

  3. 【原】FMDB源码阅读(三)

    [原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...

  4. 【原】AFNetworking源码阅读(三)

    [原]AFNetworking源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇的话,主要是讲了如何通过构建一个request来生成一个data tas ...

  5. 【原】SDWebImage源码阅读(三)

    [原]SDWebImage源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1.SDWebImageDownloader中的downloadImageWithURL 我们 ...

  6. Cwinux源码解析(三)

    我在我的 薛途的博客 上发表了新的文章,欢迎各位批评指正. Cwinux源码解析(三)

  7. 一个普通的 Zepto 源码分析(三) - event 模块

    一个普通的 Zepto 源码分析(三) - event 模块 普通的路人,普通地瞧.分析时使用的是目前最新 1.2.0 版本. Zepto 可以由许多模块组成,默认包含的模块有 zepto 核心模块, ...

  8. vueJs 源码解析 (三) 具体代码

    vueJs 源码解析 (三) 具体代码 在之前的文章中提到了 vuejs 源码中的 架构部分,以及 谈论到了 vue 源码三要素 vm.compiler.watcher 这三要素,那么今天我们就从这三 ...

  9. Android源码浅析(三)——Android AOSP 5.1.1源码的同步sync和编译make,搭建Samba服务器进行更便捷的烧录刷机

    Android源码浅析(三)--Android AOSP 5.1.1源码的同步sync和编译make,搭建Samba服务器进行更便捷的烧录刷机 最近比较忙,而且又要维护自己的博客,视频和公众号,也就没 ...

随机推荐

  1. html article标签 语法

    html article标签 语法 article标签有什么作用?直线电机生产厂家 作用:html中article标签的作用是规定独立的自包含内容,其中外部内容是来自一个外部的新闻提供者的一篇新文章, ...

  2. Devexpress MVC GridView / CardView (持续更新)

    //获取gridview里面的combo box 显示的文本 //获取某个column在gridview的 index RightGridView.GetColumnByField("Fun ...

  3. 测试常用shell语句——数值,数组类型;函数创建

    一.特殊类型的变量 shell下默认的变量类型为字符串类型 1,数值类型 如果进行数值运算,有这么几种方法 方法一: declare -i sum sum=+ echo $sum 方法二: sum=$ ...

  4. 从头开始学习Vuex

    一.前言 当我们的应用遇到多个组件共享状态时,会需要多个组件依赖于同一状态抑或是来自不同视图的行为需要变更同一状态.以前的解决办法: a.将数据以及操作数据的行为都定义在父组件; b.将数据以及操作数 ...

  5. 点云网格化算法---MPA

    MPA网格化算法思路 第一步:初始化一个种子三角面.(随机选点,基于该点进行临近搜索到第二点:在基于该线段中点临近搜索到第三点) 图1 第二步:在种子三角面的基础上,进行面片的扩充,利用边的中点进行临 ...

  6. python 调用c++类方法(1)

    myTest.cpp: #include<iostream> #include<vector> class MyTest { public: MyTest(); ~MyTest ...

  7. ACL 2019 分析

    ACL 2019 分析 word embedding 22篇! Towards Unsupervised Text Classification Leveraging Experts and Word ...

  8. ICML 2019 分析

    ICML 2019 分析 Word Embeddings Understanding the Origins of Bias in Word Embeddings Popular word embed ...

  9. 阶段3 1.Mybatis_10.JNDI扩展知识_2 补充-JNDI搭建maven的war工程

    使用骨架 src下创建test目录 再新建java和resources两个Directory test下面创建java java的目录,让他作为源码的跟目录 test下的java文件夹 选择 完成之后 ...

  10. Jmeter之线程组(默认)

    Jmeter中的采样器必须要基于线程组. 一.添加线程组 在测试计划上右键,然后选择,如下图: 二.线程组界面 三.线程组界面配置说明 1.名称:线程组自定义名称: 2.注释:添加的一些备注说明信息, ...