HBase 0.99 源代码分析 - Master启动过程(2)

本文详细分析了HBase 0.99版本中HMaster.finishActiveMasterInitialization方法,涵盖初始化Master组件、启动服务线程、ZooKeeper状态设置、Region Server管理等多个关键步骤。涉及内容包括filesystem manager、server manager、load balancer、assignment manager等的初始化与管理,以及在集群启动和故障转移中的作用。
摘要由CSDN通过智能技术生成

下面继续从HMaster.finishActiveMasterInitialization方法开始分析HBase 0.99 Master启动过程。HMaster.finishActiveMasterInitialization方法主要完成如下功能:

1. 初始化Master功能组件:file system manager, server manager, assignment manager, region server tracker 等。

2. 启动服务线程:balancer,catalog janitor, executor services 等。

3. 在ZooKeeper中设置集群状态为UP

4. 等待Region server登录

5. 如果需要的话,拆分Log, 执行数据恢复

6. 分配meta, namespace和region

7. 处理集群启动或master failover

8. 调用coprocessor

HMaster.finishActiveMasterInitialization方法源代码比较长,下面我们逐步进行分析。

  private void finishActiveMasterInitialization(MonitoredTask status)
      throws IOException, InterruptedException, KeeperException, CoordinatedStateException {

    isActiveMaster = true;

    /*
     * We are active master now... go initialize components we need to run.
     * Note, there may be dross in zk from previous runs; it'll get addressed
     * below after we determine if cluster startup or failover.
     */

    status.setStatus("Initializing Master file system");

    this.masterActiveTime = System.currentTimeMillis();
    // TODO: Do this using Dependency Injection, using PicoContainer, Guice or Spring.
    this.fileSystemManager = new MasterFileSystem(this, this);

    // publish cluster ID
    status.setStatus("Publishing Cluster ID in ZooKeeper");
    ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());
    this.serverManager = createServerManager(this, this);

    synchronized (this) {
      if (shortCircuitConnection == null) {
        shortCircuitConnection = createShortCircuitConnection();
        metaTableLocator = new MetaTableLocator();
      }
    }

    // Invalidate all write locks held previously
    this.tableLockManager.reapWriteLocks();

    this.tableStateManager = new TableStateManager(this);
    this.tableStateManager.start();

    status.setStatus("Initializing ZK system trackers");
    initializeZKBasedSystemTrackers();

    // initialize master side coprocessors before we start handling requests
    status.setStatus("Initializing master coprocessors");
    this.cpHost = new MasterCoprocessorHost(this, this.conf);

上面代码执行了如下功能:

1. 设置本Master的isActiveMaster标志为true

2. 设置masterActiveTime为当前系统时间

3. 初始化filesystem manager类MasterFileSystem,该类包装了Master与底层文件系统交互时的一些操作,例如Log分割,检查文件系统状态等。初始化时读取配置并设置HBase跟路径,临时路径等,并初始化SplitLogManager

4. 向ZooK

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值