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 class DatanodeManager {
|
|||
public boolean shouldAvoidStaleDataNodesForWrite() {
|
||||
// If # stale exceeds maximum staleness ratio, disable stale
|
||||
// datanode avoidance on the write path
|
||||
return avoidStaleDataNodesForWrite &&
|
||||
return avoidStaleDataNodesForWrite && numStaleNodes > 0 &&
|
||||
(numStaleNodes <= heartbeatManager.getLiveDatanodeCount()
|
||||
* ratioUseStaleDataNodesForWrite);
|
||||
}
|
||||
|
|
|
@ -1664,4 +1664,16 @@ public class TestReplicationPolicy extends BaseReplicationPolicyTest {
|
|||
assertNotEquals(0,
|
||||
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