NameNode启动源码分析 #7

Merged
zeekling merged 3 commits from namenode into master 2023-11-05 04:00:12 +00:00
Showing only changes of commit 027d9e5ef0 - Show all commits

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) {
``` ```