当前位置:网站首页>DataNode的启动流程
DataNode的启动流程
2022-06-11 18:02:00 【thoughtCodes】
LD is tigger forever,CG are not brothers forever, throw the pot and shine.
Efficient work is better than attitude。All right, hide it。Advantages should be hidden.
talk is selected, show others the code,Keep progress,make a better result.
目录
概述
hadoop datanode 数据服务的源码解析
正文:
数据服务的源码
1.初始化DataXceiverServer
2.初始化HTTP服务
3.初始化DN的RPC服务端
4.DN向NN(NameNode )注册
5.向NN发送心跳
如下源码:
storage = new DataStorage();
// global DN settings
registerMXBean();
// 初始化 DataXceiver
initDataXceiver();
// 启动 HttpServer
startInfoServer();
pauseMonitor = new JvmPauseMonitor();
pauseMonitor.init(getConf());
pauseMonitor.start();
// BlockPoolTokenSecretManager is required to create ipc server.
this.blockPoolTokenSecretManager = new BlockPoolTokenSecretManager();
// Login is done by now. Set the DN user name.
dnUserName = UserGroupInformation.getCurrentUser().getUserName();
LOG.info(“dnUserName = {}”, dnUserName);
LOG.info(“supergroup = {}”, supergroup);
// 初始化 RPC 服务
initIpcServer();
metrics = DataNodeMetrics.create(getConf(), getDisplayName());
peerMetrics = dnConf.peerStatsEnabled ?
DataNodePeerMetrics.create(getDisplayName(), getConf()) : null;
metrics.getJvmMetrics().setPauseMonitor(pauseMonitor);
ecWorker = new ErasureCodingWorker(getConf(), this);
blockRecoveryWorker = new BlockRecoveryWorker(this);
// 创建 BlockPoolManager
blockPoolManager = new BlockPoolManager(this);
// 心跳管理
blockPoolManager.refreshNamenodes(getConf());
// Create the ReadaheadPool from the DataNode context so we can
// exit without having to explicitly shutdown its thread pool.
readaheadPool = ReadaheadPool.getInstance();
saslClient = new SaslDataTransferClient(dnConf.getConf(),
dnConf.saslPropsResolver, dnConf.trustedChannelResolver);
saslServer = new SaslDataTransferServer(dnConf, blockPoolTokenSecretManager);
startMetricsLogger();
if (dnConf.diskStatsEnabled) {
diskMetrics = new DataNodeDiskMetrics(this,
dnConf.outliersReportIntervalMs);
}
}
2.1 初始化 DataXceiverServer
点击 initDataXceiver
private void initDataXceiver() throws IOException {
// dataXceiverServer 是一个服务,DN 用来接收客户端和其他 DN 发送过来的数据服务
this.dataXceiverServer = new Daemon(threadGroup, xserver);
this.threadGroup.setDaemon(true); // auto destroy when empty
…
2.2 初始化 HTTP 服务
点击 startInfoServer();
private void startInfoServer()
throws IOException {
// SecureDataNodeStarter will bind the privileged port to the channel if
// the DN is started by JSVC, pass it along.
ServerSocketChannel httpServerChannel = secureResources != null ?
secureResources.getHttpServerChannel() : null;
httpServer = new DatanodeHttpServer(getConf(), this, httpServerChannel);
httpServer.start();
if (httpServer.getHttpAddress() != null) {
infoPort = httpServer.getHttpAddress().getPort();
}
if (httpServer.getHttpsAddress() != null) {
infoSecurePort = httpServer.getHttpsAddress().getPort();
}
}
DatanodeHttpServer.java
public DatanodeHttpServer(final Configuration conf,
final DataNode datanode,
final ServerSocketChannel externalHttpChannel)
throws IOException {
… …
HttpServer2.Builder builder = new HttpServer2.Builder()
.setName(“datanode”)
.setConf(confForInfoServer)
.setACL(new AccessControlList(conf.get(DFS_ADMIN, " ")))
.hostName(getHostnameForSpnegoPrincipal(confForInfoServer))
.addEndpoint(URI.create(“http://localhost:” + proxyPort))
.setFindPort(true);
.
2.3 初始化 DN 的 RPC 服务端
private void initIpcServer() throws IOException {
InetSocketAddress ipcAddr = NetUtils.createSocketAddr(
getConf().getTrimmed(DFS_DATANODE_IPC_ADDRESS_KEY));
… …
ipcServer = new RPC.Builder(getConf())
.setProtocol(ClientDatanodeProtocolPB.class)
.setInstance(service)
.setBindAddress(ipcAddr.getHostName())
.setPort(ipcAddr.getPort())
.setNumHandlers(
getConf().getInt(DFS_DATANODE_HANDLER_COUNT_KEY,
DFS_DATANODE_HANDLER_COUNT_DEFAULT)).setVerbose(false)
.setSecretManager(blockPoolTokenSecretManager).build();
… …
设计思路
相关代码如下:
完整版下载: hadoopDataNode解析
小结:
主要讲述了自己的一些体会,里面有许多不足,请大家指正~
参考资料和推荐阅读
深度开源: link
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~
边栏推荐
- 夜神安装apk,以及bp代理
- SQL error injection 1
- 排序的循环链表
- [collect first and use it sooner or later] 49 Flink high-frequency interview questions series (I)
- How ZABBIX can customize MySQL monitoring items and trigger alarms
- Oracle高级数据库复习
- SISO Decoder for min-sum(补充章节2)
- SISO decoder for a general (n,n-1) SPC code(补充章节3)
- [C语言]用结构体把平均分和低于等于平均分的学生数据输出
- TR-069 protocol introduction
猜你喜欢

How ZABBIX can customize MySQL monitoring items and trigger alarms

任意用户密码重置的10种方式

ctf入门

ctfhub-sql布尔盲注

upload-labs通关未半而中道崩殂

SISO decoder for a general (n,n-1) SPC code(补充章节3)
![Spring 2021 daily question [end of week4]](/img/b3/2f5a66b0d4374db3d4db0b71d72f7e.jpg)
Spring 2021 daily question [end of week4]

Ctfhub SQL Boolean blind annotation

ACL 2022: is it no longer difficult to evaluate word polysemy? A new benchmark "dibimt"

Jsfinder, wafw00f installation, nmap configuration (msvcr120.dll file is missing)
随机推荐
MMA-Self-defining function
Is it good or not to open a stock account on the flush? Is it safe?
Hello go (XII). Go language common standard library II
SISO decoder for a general (n, n-1) SPC code (supplementary Chapter 3)
密评-----
async导致函数结果出乎意料,改变原来代码的意图;await is only valid in async functions and the top level bodies of modules
【C】 Compilation preprocessing and environment
vulhub
Hwang
软件需求工程复习
Cryptology Summary
求字符串中最大的 3 位相同数字
[C语言]对一个数组的元素排序后平移元素
[golang] leetcode - 292 Nim games (Mathematics)
ACL 2022:评估单词多义性不再困扰?一种新的基准“DIBIMT”
Reading summary of nacos2.x source code
【新手上路常见问答】关于项目管理
[untitled]
Can 400 fans earn 20W a month? How did you do it?
Ctfhub SQL Boolean blind annotation