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. 状态管理-vuex

    1.使用vuex // 使用vuex // 第一步:装包npm i vuex -S // 第二步: import Vuex from 'vuex' Vue.use(Vuex) // 第三步: cons ...

  2. jquery empty选择器 语法

    jquery empty选择器 语法 作用::empty 选择器选取空的元素.空元素指的是不包含子元素或文本的元素.直线电机滑台 语法:$(":empty") jquery emp ...

  3. Replicate(网络复制),ActorRole(角色),Ownership(所有权)以及RPC(远程调用)等等

    I. Replication Replication指的是 从服务端向客户端 传递数据和信息的行为.注意是单向的,不会从客户端传递信息和数据到服务端. 假设一个Actor被设置为Replicates, ...

  4. C#中的事件委托

    C#中的事件与委托,对于我们写业务代码的程序员来说不常用,这就会导致经常忘记,这边再温习一下. //委托 public delegate void MyEventDelegateHandler(str ...

  5. js基本数据类型+判断数据类型方法

    摘要:不管是什么类型的,Object.prototype.toString.call();都可以判断出其具体的类型,简单基本类型(String.Number.Boolean.Null.Undefine ...

  6. [LeetCode]-011-Longest Common Prefix

    Write a function to find the longest common prefix string amongst an array of strings. []=>" ...

  7. CentOS7修改计算机名!

    https://www.cnblogs.com/acgpiano/p/4170546.html sudo hostnamectl set-hostname <host-name>

  8. QPS、TPS、PV、UV、GMV、IP、RPS

    摘自:https://www.citrons.cn/jishu/226.html 关于 QPS.TPS.PV.UV.GMV.IP.RPS 这些词语,看起来好像挺专业.但实际上,我认为是这是每个程序员必 ...

  9. 使用collection查询集合属性

    介绍resultMap中使用collection查询集合属性 业务需求,查询部门中的多个人员 public class Department { private Integer id; private ...

  10. AAAI 2019 分析

    AAAI 2019 分析 Google Scholar 订阅 CoKE : Word Sense Induction Using Contextualized Knowledge Embeddings ...