namenode启动源码分析

This commit is contained in:
LingZhaoHui 2023-11-05 11:59:29 +08:00
parent 22117d178d
commit 027d9e5ef0
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC

View File

@ -153,6 +153,7 @@ private void startCommonServices(Configuration conf) throws IOException {
// 启动所有插件 // 启动所有插件
for (ServicePlugin p: plugins) { for (ServicePlugin p: plugins) {
try { try {
// 调用插件的start接口需要插件自己实现需要实现接口ServicePlugin
p.start(this); p.start(this);
} catch (Throwable t) { } catch (Throwable t) {
LOG.warn("ServicePlugin " + p + " could not be started", t); LOG.warn("ServicePlugin " + p + " could not be started", t);
@ -202,8 +203,7 @@ void startCommonServices(Configuration conf, HAContext haContext) throws IOExcep
// 注册快照管理器 // 注册快照管理器
snapshotManager.registerMXBean(); snapshotManager.registerMXBean();
InetSocketAddress serviceAddress = NameNode.getServiceAddress(conf, true); InetSocketAddress serviceAddress = NameNode.getServiceAddress(conf, true);
this.nameNodeHostName = (serviceAddress != null) ? this.nameNodeHostName = (serviceAddress != null) ? serviceAddress.getHostName() : "";
serviceAddress.getHostName() : "";
} }
``` ```
@ -219,6 +219,7 @@ void startCommonServices(Configuration conf, HAContext haContext) throws IOExcep
```java ```java
public void activate(Configuration conf, long blockTotal) { public void activate(Configuration conf, long blockTotal) {
pendingReconstruction.start(); pendingReconstruction.start();
// 初始化datanodeManager
datanodeManager.activate(conf); datanodeManager.activate(conf);
this.redundancyThread.setName("RedundancyMonitor"); this.redundancyThread.setName("RedundancyMonitor");
this.redundancyThread.start(); this.redundancyThread.start();
@ -231,5 +232,3 @@ public void activate(Configuration conf, long blockTotal) {
``` ```