HDFS-14366. Improve HDFS append performance. Contributed by Chao Sun.

(cherry picked from commit ff06ef0631cb8a0f67bbc39b5b5a1b0a81ca3b3c)
This commit is contained in:
Inigo Goiri 2019-03-15 11:06:42 -07:00
parent 9b8044d00b
commit 525f4e52f3

View File

@ -1256,9 +1256,13 @@ public void verifyReplication(String src,
*/
public boolean isSufficientlyReplicated(BlockInfo b) {
// Compare against the lesser of the minReplication and number of live DNs.
final int replication =
Math.min(minReplication, getDatanodeManager().getNumLiveDataNodes());
return countNodes(b).liveReplicas() >= replication;
final int liveReplicas = countNodes(b).liveReplicas();
if (liveReplicas >= minReplication) {
return true;
}
// getNumLiveDataNodes() is very expensive and we minimize its use by
// comparing with minReplication first.
return liveReplicas >= getDatanodeManager().getNumLiveDataNodes();
}
/** Get all blocks with location information from a datanode. */