HDFS-14171. Performance improvement in Tailing EditLog. Contributed by Kenneth Yang.
This commit is contained in:
parent
128f340f4f
commit
e9a005dfcf
|
@ -567,7 +567,12 @@ class BlockManagerSafeMode {
|
||||||
*/
|
*/
|
||||||
private boolean areThresholdsMet() {
|
private boolean areThresholdsMet() {
|
||||||
assert namesystem.hasWriteLock();
|
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) {
|
synchronized (this) {
|
||||||
return blockSafe >= blockThreshold && datanodeNum >= datanodeThreshold;
|
return blockSafe >= blockThreshold && datanodeNum >= datanodeThreshold;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue