Hbase0.96源代码之HMaster(三)Hmaster主要循环
2014-05-21 02:02
281 查看
1,Master初始化
1.1
[code] if (!this.stopped) { finishInitialization(startupStatus, false); loop(); }
1.2 finishInitialization(),这里主要完成master组件components:filesystem manager,servermanager,assignmentmanager,regionservertracker, catalogtracker等
1.2.1 设置为active master
[code]isActiveMaster = true;
1.2.2 生成MasterFileSystem(fileSystemManager),管理一些文件系统的操作,包含deleteregion,deletetable,modifyColumn,addColumn,deleteFamilyFromFS以及splitlog,splitMetaLog等
1.2.2.1 check rootdir以及temp目录都存在,且清除temp目录
[code] this.oldLogDir = createInitialFileSystemLayout();
1.2.2.1.1clean tempdir
[code]// 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的
[code] // 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?
[code]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的创建
[code]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
[code]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快照管理祥光
[code] 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主要循环becomeActiveMaster
- Hbase0.96源代码之HMaster(一)
- Hbase0.96源码之HMaster(二)Hmaster主要循环becomeActiveMaster
- 重载消息循环主要代码
- HBase1.0.0版源码分析之HMaster启动代码分析(1)
- HBase1.0.0版源码分析之HMaster启动代码分析(2)
- HBase源码解析(二) HMaster主要类成员解析
- HBase主要API总结及代码示例
- 随机调用iframe JS 的广告代码,随页面滚动广告循环播放。。
- 用VC写Assembly代码(5) --循环的使用(一)
- CRC校验实现-实验报告(附主要实现代码)
- 上下循环滚动代码JAVASCRIPT
- Linux内核2.6.14源码分析-双向循环链表代码分析(巨详细)
- 教主网络僵尸服务端主要代码
- 图片左右循环连续滚动代码,解决marquee的留白问题
- 关于Basic程序解释器及编译原理的简单化(1)---Basic器的语法分析及主要代码
- 循环队列代码(支持对共享内存的操作)
- 主要搜索引擎(Google和百度、雅虎)的站内搜索代码
- 建立不规则窗体的主要代码
- 关于Basic程序解释器及编译原理的简单化(1)---Basic器的语法分析及主要代码