HBase源代码调试(6)-HRegion的启动

前提:debug configurations里面

MainClass : HRegion

Arguments: .META.


-----------------------------------------------

第一步构造HLog 对象,构造函数中

首先在/tmp/hbase-user下创建 hlog.META.1357446070560文件夹, 数字串是hregion启动的时间(currentTimeMills).

然后看有无 ".oldlogs'文件夹, 无则创建

然后是读取各种conf里面的设置 如 hbase.regionserver.maxlogs, default is 32

then under the hlog.META.XXXXX/ , create a file named 'hlog.135747xxxx', still use the System.currentTimeMills()

then call ->Writer createWriter(); ->SequenceFile$Writer.init()

        it will call writeFileHeader, and put VERSION, keyClass etc into header

launch a LogSyncer Thread

new a WALCoprocessorHost




In method  initializeRegionInternals

      ThreadPoolExecutor storeOpenerThreadPool =
        getStoreOpenAndCloseThreadPool(
          "StoreOpenerThread-" + this.regionInfo.getRegionNameAsString());
      CompletionService<Store> completionService =
        new ExecutorCompletionService<Store>(storeOpenerThreadPool);

      // initialize each store in parallel
      for (final HColumnDescriptor family : htableDescriptor.getFamilies()) {
        status.setStatus("Instantiating store for column family " + family);
        completionService.submit(new Callable<Store>() {
          public Store call() throws IOException {
            return instantiateHStore(tableDir, family);
          }
        });
可以看到对每个family,启动一个线程, 执行
instantiateHStore
返回一个new Store对象,而在store的构造函数中,调用了method

 this.storefiles = sortAndClone(loadStoreFiles());

in loadStoreFiles,会启动线程

     completionService.submit(new Callable<StoreFile>() {
        public StoreFile call() throws IOException {
          StoreFile storeFile = new StoreFile(fs, p, conf, cacheConf,
              family.getBloomFilterType(), dataBlockEncoder);
          passSchemaMetricsTo(storeFile);
          storeFile.createReader();
          return storeFile;
        }
      });

在createReader的过程中读取分析HFile



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值