给BPServiceActor增加注释

This commit is contained in:
LingZhaoHui 2024-07-28 20:24:00 +08:00
parent 629d31909f
commit ddc50a86f7
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC

View File

@ -533,6 +533,7 @@ private int calculateBlockReportPBSize(
return reportSize;
}
// 向NN发送心跳的主要实现
HeartbeatResponse sendHeartBeat(boolean requestBlockReportLease)
throws IOException {
scheduler.scheduleNextHeartbeat();
@ -587,6 +588,7 @@ void sendLifelineForTests() throws IOException {
}
//This must be called only by BPOfferService
// 入口函数开始向NN注册当前DN
void start() {
if ((bpThread != null) && (bpThread.isAlive())) {
//Thread is started already
@ -827,6 +829,7 @@ void register(NamespaceInfo nsInfo) throws IOException {
while (shouldRun()) {
try {
// Use returned registration from namenode with updated fields
// 向NN注册DataNodde
newBpRegistration = bpNamenode.registerDatanode(newBpRegistration);
newBpRegistration.setNamespaceInfo(nsInfo);
bpRegistration = newBpRegistration;
@ -858,6 +861,7 @@ void register(NamespaceInfo nsInfo) throws IOException {
fullBlockReportLeaseId = 0;
// random short delay - helps scatter the BR from all DNs
// 定时汇报block块信息给NN
scheduler.scheduleBlockReport(dnConf.initialBlockReportDelayMs, true);
}
@ -875,6 +879,7 @@ private void sleepAndLogInterrupts(int millis,
* No matter what kind of exception we get, keep retrying to offerService().
* That's the loop that connects to the NameNode and provides basic DataNode
* functionality.
* 当前类本身就是一个异步线程当前函数为线程的入口函数线程由start函数启动
*
* Only stop when "shouldRun" or "shouldServiceRun" is turned off, which can
* happen either at shutdown or due to refreshNamenodes.
@ -888,6 +893,7 @@ public void run() {
// init stuff
try {
// setup storage
// 开始连接NN并且注册当前DN,主要分为两个阶段1握手并且校验NS等信息2向NN注册当前DN
connectToNNAndHandshake();
break;
} catch (IOException ioe) {