NameNode 主要启动逻辑如下:
NameNode.initMetrics(conf, this.getRole());
StartupProgressMetrics.register(startupProgress);
if (NamenodeRole.NAMENODE == role) {
startHttpServer(conf);
}
loadNamesystem(conf);
rpcServer = createRpcServer(conf);
if (NamenodeRole.NAMENODE == role) {
httpServer.setNameNodeAddress(getNameNodeAddress());
httpServer.setFSImage(getFSImage());
}
pauseMonitor = new JvmPauseMonitor(conf);
pauseMonitor.start();
metrics.getJvmMetrics().setPauseMonitor(pauseMonitor);
startCommonServices(conf);
loadNamesystem
createRpcServer初始化一个NameNodeRpcServer
startCommonServices中启动了HTTPServer和RPCServer
NameNodeHttpServer
NameNodeRpcServer handling all of the RPC calls to the NameNode.
NameNodeRpcServer处理了NameNode的各种RPC请求(来自DataNode和Client)
构造函数的结构中已经说明了一切 一连好几组下面这种结构:
XXXProtocolServerSideTranslatorPB XXXProtocolServerTranslator =
new XXXProtocolServerSideTranslatorPB(this);
BlockingService XXXPbService = XXXProtocol
.newReflectiveBlockingService(XXXProtocolServerTranslator);
配置项dfs.namenode.handler.count用来指定NameNodeRpcServer中Processor线程数