HDFS-14171. Performance improvement in Tailing EditLog. Contributed by Kenneth Yang.
(cherry picked from commite9a005dfcf
) (cherry picked from commitc48640ffbd
)
This commit is contained in:
parent
de2b04a74b
commit
f24684ca9c
|
@ -561,7 +561,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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue