HDFS-14366. Improve HDFS append performance. Contributed by Chao Sun.
(cherry picked from commit ff06ef0631
)
This commit is contained in:
parent
43e8ac6097
commit
4eb0497091
|
@ -1483,9 +1483,13 @@ public class BlockManager implements BlockStatsMXBean {
|
||||||
*/
|
*/
|
||||||
public boolean isSufficientlyReplicated(BlockInfo b) {
|
public boolean isSufficientlyReplicated(BlockInfo b) {
|
||||||
// Compare against the lesser of the minReplication and number of live DNs.
|
// Compare against the lesser of the minReplication and number of live DNs.
|
||||||
final int replication =
|
final int liveReplicas = countNodes(b).liveReplicas();
|
||||||
Math.min(minReplication, getDatanodeManager().getNumLiveDataNodes());
|
if (liveReplicas >= minReplication) {
|
||||||
return countNodes(b).liveReplicas() >= replication;
|
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. */
|
/** Get all blocks with location information from a datanode. */
|
||||||
|
|
Loading…
Reference in New Issue