前提: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