增加NameNode启动过程注释
This commit is contained in:
parent
e1d4e6e26d
commit
ac56c2f364
@ -805,6 +805,7 @@ static FSNamesystem loadFromDisk(Configuration conf) throws IOException {
|
||||
|
||||
long loadStart = monotonicNow();
|
||||
try {
|
||||
// 加载FSImage,将其和EditLog合并生成新的FSImage,因此可能启动的是欧会比较慢。
|
||||
namesystem.loadFSImage(startOpt);
|
||||
} catch (IOException ioe) {
|
||||
LOG.warn("Encountered exception loading fsimage", ioe);
|
||||
@ -1302,14 +1303,17 @@ void startCommonServices(Configuration conf, HAContext haContext) throws IOExcep
|
||||
writeLock();
|
||||
this.haContext = haContext;
|
||||
try {
|
||||
//创建NameNodeResourceChecker,并立即检查一次
|
||||
nnResourceChecker = new NameNodeResourceChecker(conf);
|
||||
checkAvailableResources();
|
||||
assert !blockManager.isPopulatingReplQueues();
|
||||
StartupProgress prog = NameNode.getStartupProgress();
|
||||
prog.beginPhase(Phase.SAFEMODE);
|
||||
//获取已完成的数据块总量
|
||||
long completeBlocksTotal = getCompleteBlocksTotal();
|
||||
prog.setTotal(Phase.SAFEMODE, STEP_AWAITING_REPORTED_BLOCKS,
|
||||
completeBlocksTotal);
|
||||
// 激活blockManager,blockManager负责管理文件系统中文件的物理块与实际存储位置的映射关系,是NameNode的核心功能之一。
|
||||
blockManager.activate(conf, completeBlocksTotal);
|
||||
} finally {
|
||||
writeUnlock("startCommonServices");
|
||||
@ -1321,6 +1325,7 @@ void startCommonServices(Configuration conf, HAContext haContext) throws IOExcep
|
||||
inodeAttributeProvider.start();
|
||||
dir.setINodeAttributeProvider(inodeAttributeProvider);
|
||||
}
|
||||
// 注册快照管理器
|
||||
snapshotManager.registerMXBean();
|
||||
InetSocketAddress serviceAddress = NameNode.getServiceAddress(conf, true);
|
||||
this.nameNodeHostName = (serviceAddress != null) ?
|
||||
|
@ -746,10 +746,10 @@ protected void initialize(Configuration conf) throws IOException {
|
||||
intervals);
|
||||
}
|
||||
}
|
||||
|
||||
//登录kerberos
|
||||
UserGroupInformation.setConfiguration(conf);
|
||||
loginAsNameNodeUser(conf);
|
||||
|
||||
// 注册监控信息
|
||||
NameNode.initMetrics(conf, this.getRole());
|
||||
StartupProgressMetrics.register(startupProgress);
|
||||
|
||||
@ -777,10 +777,13 @@ protected void initialize(Configuration conf) throws IOException {
|
||||
if (NamenodeRole.NAMENODE == role) {
|
||||
startHttpServer(conf);
|
||||
}
|
||||
|
||||
// 从本地加载FSImage,并且与Editlog合并产生新的FSImage
|
||||
loadNamesystem(conf);
|
||||
//TODO 待确认用途
|
||||
startAliasMapServerIfNecessary(conf);
|
||||
|
||||
//创建rpcserver,封装了NameNodeRpcServer、ClientRPCServer
|
||||
//支持ClientNameNodeProtocol、DataNodeProtocolPB等协议
|
||||
rpcServer = createRpcServer(conf);
|
||||
|
||||
initReconfigurableBackoffKey();
|
||||
@ -801,6 +804,7 @@ protected void initialize(Configuration conf) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
//启动执行多个重要的工作线程
|
||||
startCommonServices(conf);
|
||||
startMetricsLogger(conf);
|
||||
}
|
||||
@ -880,6 +884,7 @@ protected NameNodeRpcServer createRpcServer(Configuration conf)
|
||||
|
||||
/** Start the services common to active and standby states */
|
||||
private void startCommonServices(Configuration conf) throws IOException {
|
||||
// 创建NameNodeResourceChecker、激活BlockManager等
|
||||
namesystem.startCommonServices(conf, haContext);
|
||||
registerNNSMXBean();
|
||||
if (NamenodeRole.NAMENODE != role) {
|
||||
@ -890,8 +895,10 @@ private void startCommonServices(Configuration conf) throws IOException {
|
||||
httpServer.setAliasMap(levelDBAliasMapServer.getAliasMap());
|
||||
}
|
||||
}
|
||||
// 启动rpc服务
|
||||
rpcServer.start();
|
||||
try {
|
||||
// 获取启动插件列表
|
||||
plugins = conf.getInstances(DFS_NAMENODE_PLUGINS_KEY,
|
||||
ServicePlugin.class);
|
||||
} catch (RuntimeException e) {
|
||||
@ -900,8 +907,10 @@ private void startCommonServices(Configuration conf) throws IOException {
|
||||
pluginsValue, e);
|
||||
throw e;
|
||||
}
|
||||
// 启动所有插件
|
||||
for (ServicePlugin p: plugins) {
|
||||
try {
|
||||
// 调用插件的start接口,需要插件自己实现,需要实现接口ServicePlugin
|
||||
p.start(this);
|
||||
} catch (Throwable t) {
|
||||
LOG.warn("ServicePlugin " + p + " could not be started", t);
|
||||
@ -1025,11 +1034,13 @@ protected NameNode(Configuration conf, NamenodeRole role)
|
||||
+ " this namenode/service.", clientNamenodeAddress);
|
||||
}
|
||||
this.haEnabled = HAUtil.isHAEnabled(conf, nsId);
|
||||
// 检查HA的状态,主要是判断当前启动的是主实例还是备实例
|
||||
state = createHAState(getStartupOption(conf));
|
||||
this.allowStaleStandbyReads = HAUtil.shouldAllowStandbyReads(conf);
|
||||
this.haContext = createHAContext();
|
||||
try {
|
||||
initializeGenericKeys(conf, nsId, namenodeId);
|
||||
// 启动NameNode
|
||||
initialize(getConf());
|
||||
state.prepareToEnterState(haContext);
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user