HDFS-15816. Fix shouldAvoidStaleDataNodesForWrite returns when no stale node in cluster. Contributed by Yang Yun.
This commit is contained in:
parent
fe633d4739
commit
970455c917
@ -1321,7 +1321,7 @@ public List<DatanodeDescriptor> getEnteringMaintenanceNodes() {
|
|||||||
public boolean shouldAvoidStaleDataNodesForWrite() {
|
public boolean shouldAvoidStaleDataNodesForWrite() {
|
||||||
// If # stale exceeds maximum staleness ratio, disable stale
|
// If # stale exceeds maximum staleness ratio, disable stale
|
||||||
// datanode avoidance on the write path
|
// datanode avoidance on the write path
|
||||||
return avoidStaleDataNodesForWrite &&
|
return avoidStaleDataNodesForWrite && numStaleNodes > 0 &&
|
||||||
(numStaleNodes <= heartbeatManager.getLiveDatanodeCount()
|
(numStaleNodes <= heartbeatManager.getLiveDatanodeCount()
|
||||||
* ratioUseStaleDataNodesForWrite);
|
* ratioUseStaleDataNodesForWrite);
|
||||||
}
|
}
|
||||||
|
@ -1664,4 +1664,16 @@ public void testChosenFailureForStorageType() {
|
|||||||
assertNotEquals(0,
|
assertNotEquals(0,
|
||||||
appender.countLinesWithMessage("NO_REQUIRED_STORAGE_TYPE"));
|
appender.countLinesWithMessage("NO_REQUIRED_STORAGE_TYPE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReduceChooseTimesIfNOStaleNode() {
|
||||||
|
for(int i = 0; i < 6; i++) {
|
||||||
|
updateHeartbeatWithUsage(dataNodes[i],
|
||||||
|
2 * HdfsServerConstants.MIN_BLOCKS_FOR_WRITE * BLOCK_SIZE, 0L,
|
||||||
|
(HdfsServerConstants.MIN_BLOCKS_FOR_WRITE - 1) * BLOCK_SIZE,
|
||||||
|
0L, 0L, 0L, 0, 0);
|
||||||
|
}
|
||||||
|
assertFalse(dnManager.shouldAvoidStaleDataNodesForWrite());
|
||||||
|
resetHeartbeatForStorages();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user