Skip to content

Commit 2222acc

Browse files
zhujianghuazhujianghua
authored andcommitted
HDFS-16234.Improve DataNodeMetrics to initialize IBR more reasonable.
1 parent 98e2781 commit 2222acc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/IncrementalBlockReportManager.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ private synchronized StorageReceivedDeletedBlocks[] generateIBRs() {
176176
}
177177
}
178178

179-
/* set blocks to zero */
180-
this.dnMetrics.resetBlocksInPendingIBR();
181-
182179
readyToSend = false;
183180
return reports.toArray(new StorageReceivedDeletedBlocks[reports.size()]);
184181
}
@@ -198,6 +195,9 @@ void sendIBRs(DatanodeProtocol namenode, DatanodeRegistration registration,
198195
// Generate a list of the pending reports for each storage under the lock
199196
final StorageReceivedDeletedBlocks[] reports = generateIBRs();
200197
if (reports.length == 0) {
198+
/* set blocks to zero */
199+
this.dnMetrics.resetBlocksInPendingIBR();
200+
201201
// Nothing new to report.
202202
return;
203203
}
@@ -212,6 +212,8 @@ void sendIBRs(DatanodeProtocol namenode, DatanodeRegistration registration,
212212
namenode.blockReceivedAndDeleted(registration, bpid, reports);
213213
success = true;
214214
} finally {
215+
/* set blocks to zero */
216+
this.dnMetrics.resetBlocksInPendingIBR();
215217

216218
if (success) {
217219
dnMetrics.addIncrementalBlockReport(monotonicNow() - startTime,

0 commit comments

Comments
 (0)