给BPServiceActor增加注释
This commit is contained in:
parent
629d31909f
commit
ddc50a86f7
@ -532,7 +532,8 @@ private int calculateBlockReportPBSize(
|
|||||||
}
|
}
|
||||||
return reportSize;
|
return reportSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 向NN发送心跳的主要实现
|
||||||
HeartbeatResponse sendHeartBeat(boolean requestBlockReportLease)
|
HeartbeatResponse sendHeartBeat(boolean requestBlockReportLease)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
scheduler.scheduleNextHeartbeat();
|
scheduler.scheduleNextHeartbeat();
|
||||||
@ -587,6 +588,7 @@ void sendLifelineForTests() throws IOException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This must be called only by BPOfferService
|
//This must be called only by BPOfferService
|
||||||
|
// 入口函数,开始向NN注册当前DN
|
||||||
void start() {
|
void start() {
|
||||||
if ((bpThread != null) && (bpThread.isAlive())) {
|
if ((bpThread != null) && (bpThread.isAlive())) {
|
||||||
//Thread is started already
|
//Thread is started already
|
||||||
@ -827,6 +829,7 @@ void register(NamespaceInfo nsInfo) throws IOException {
|
|||||||
while (shouldRun()) {
|
while (shouldRun()) {
|
||||||
try {
|
try {
|
||||||
// Use returned registration from namenode with updated fields
|
// Use returned registration from namenode with updated fields
|
||||||
|
// 向NN注册DataNodde
|
||||||
newBpRegistration = bpNamenode.registerDatanode(newBpRegistration);
|
newBpRegistration = bpNamenode.registerDatanode(newBpRegistration);
|
||||||
newBpRegistration.setNamespaceInfo(nsInfo);
|
newBpRegistration.setNamespaceInfo(nsInfo);
|
||||||
bpRegistration = newBpRegistration;
|
bpRegistration = newBpRegistration;
|
||||||
@ -858,6 +861,7 @@ void register(NamespaceInfo nsInfo) throws IOException {
|
|||||||
fullBlockReportLeaseId = 0;
|
fullBlockReportLeaseId = 0;
|
||||||
|
|
||||||
// random short delay - helps scatter the BR from all DNs
|
// random short delay - helps scatter the BR from all DNs
|
||||||
|
// 定时汇报block块信息给NN
|
||||||
scheduler.scheduleBlockReport(dnConf.initialBlockReportDelayMs, true);
|
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().
|
* 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
|
* That's the loop that connects to the NameNode and provides basic DataNode
|
||||||
* functionality.
|
* functionality.
|
||||||
|
* 当前类本身就是一个异步线程,当前函数为线程的入口函数,线程由start函数启动。
|
||||||
*
|
*
|
||||||
* Only stop when "shouldRun" or "shouldServiceRun" is turned off, which can
|
* Only stop when "shouldRun" or "shouldServiceRun" is turned off, which can
|
||||||
* happen either at shutdown or due to refreshNamenodes.
|
* happen either at shutdown or due to refreshNamenodes.
|
||||||
@ -888,6 +893,7 @@ public void run() {
|
|||||||
// init stuff
|
// init stuff
|
||||||
try {
|
try {
|
||||||
// setup storage
|
// setup storage
|
||||||
|
// 开始连接NN并且注册当前DN,主要分为两个阶段:1、握手,并且校验NS等信息。2、向NN注册当前DN。
|
||||||
connectToNNAndHandshake();
|
connectToNNAndHandshake();
|
||||||
break;
|
break;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
@ -1527,4 +1533,4 @@ void stopCommandProcessingThread() {
|
|||||||
commandProcessingThread.interrupt();
|
commandProcessingThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user