第二篇 hbase2.4.2 源码分析 RegionServer启动流程
前言
1.看什么? 看HRegionServer类说明 看main()入口 看初始化了哪些重要组件 如何进行远程调用 如何看:看过程中画图,或者把方法的调用关系,对象的调用按照调用关系记录下来,本文按照第二种方式进行编写一、HRegionServer类继承关系
看什么?
看类说明,看继承关系
从哲学角度看:这是性质问题
HRegionServer 是个线程,实现 RegionServerServices, LastSequenceId, ConfigurationObserver 几个接口,既然是线程,肯定有run方法
/**
* HRegionServer makes a set of HRegions available to clients. It checks in with
* the HMaster. There are many HRegionServers in a single HBase deployment.
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
@SuppressWarnings({
"deprecation"})
public class HRegionServer extends Thread implements
RegionServerServices, LastSequenceId, ConfigurationObserver {
二、HRegionServer.main入口分析
1.main入口
/**
* @see org.apache.hadoop.hbase.regionserver.HRegionServerCommandLine
*/
public static void main(String[] args) {
LOG.info("STARTING executorService " + HRegionServer.class.getSimpleName());
VersionInfo.logVersion();
Configuration conf = HBaseConfiguration.create();
@SuppressWarnings("unchecked")
Class<? extends HRegionServer> regionServerClass = (Class<? extends HRegionServer>) conf
.getClass(HConstants.REGION_SERVER_IMPL, HRegionServer.class);
new HRegionServerCommandLine(regionServerClass).doMain(args);
}
HRegionServerCommandLine.doMain()如下
/**
* Parse and run the given command line. This may exit the JVM if
* a nonzero exit code is returned from <code>run()</code>.
*/
public void doMain(String args[]) {
try {
//核心代码,为什么是核心代码?除了它,还有其他值得看的吗?
int ret <

本文详细解读了HBase 2.4.2中RegionServer的启动过程,包括类结构、main入口剖析、核心服务初始化和与Master的RPC通信机制。重点介绍了run()方法中启动的服务和gRPC框架的应用。
最低0.47元/天 解锁文章
3126

被折叠的 条评论
为什么被折叠?



