HDFS-13048. LowRedundancyReplicatedBlocks metric can be negative

This commit is contained in:
Akira Ajisaka 2018-02-02 14:33:56 +09:00
parent b0627c891b
commit 4aef8bd2ef
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
2 changed files with 16 additions and 1 deletions

View File

@ -365,7 +365,7 @@ class LowRedundancyBlocks implements Iterable<BlockInfo> {
NameNode.blockStateChangeLog.debug(
"BLOCK* NameSystem.LowRedundancyBlock.remove: Removing block" +
" {} from priority queue {}", block, i);
decrementBlockStat(block, priLevel, oldExpectedReplicas);
decrementBlockStat(block, i, oldExpectedReplicas);
return true;
}
}

View File

@ -123,6 +123,21 @@ public class TestLowRedundancyBlockQueues {
verifyBlockStats(queues, 2, 3, 2, 0, 0);
}
@Test
public void testRemoveWithWrongPriority() {
final LowRedundancyBlocks queues = new LowRedundancyBlocks();
final BlockInfo corruptBlock = genBlockInfo(1);
assertAdded(queues, corruptBlock, 0, 0, 3);
assertInLevel(queues, corruptBlock,
LowRedundancyBlocks.QUEUE_WITH_CORRUPT_BLOCKS);
verifyBlockStats(queues, 0, 1, 0, 0, 0);
// Remove with wrong priority
queues.remove(corruptBlock, LowRedundancyBlocks.QUEUE_LOW_REDUNDANCY);
// Verify the number of corrupt block is decremented
verifyBlockStats(queues, 0, 0, 0, 0, 0);
}
@Test
public void testStripedBlockPriorities() throws Throwable {
int dataBlkNum = ecPolicy.getNumDataUnits();