HDFS-14171. Performance improvement in Tailing EditLog. Contributed by Kenneth Yang.

(cherry picked from commit e9a005dfcf)
This commit is contained in:
Wei-Chiu Chuang 2018-12-28 10:34:18 -08:00
parent 9bfea98746
commit c48640ffbd
1 changed files with 6 additions and 1 deletions

View File

@ -567,7 +567,12 @@ class BlockManagerSafeMode {
*/
private boolean areThresholdsMet() {
assert namesystem.hasWriteLock();
int datanodeNum = blockManager.getDatanodeManager().getNumLiveDataNodes();
// Calculating the number of live datanodes is time-consuming
// in large clusters. Skip it when datanodeThreshold is zero.
int datanodeNum = 0;
if (datanodeThreshold > 0) {
datanodeNum = blockManager.getDatanodeManager().getNumLiveDataNodes();
}
synchronized (this) {
return blockSafe >= blockThreshold && datanodeNum >= datanodeThreshold;
}