boolean corruptedLen = false;
int reportIndex = 0;
for(Map.Entry<DatanodeStorage, BlockListAsLongs> kvPair : perVolumeBlockLists.entrySet()) {
DatanodeStorage dnStorage = kvPair.getKey();
BlockListAsLongs blockList = kvPair.getValue();
// Walk the list of blocks until we find one each to corrupt the
// generation stamp and length, if so requested.
for (int i = 0; i < blockList.getNumberOfBlocks(); ++i) {
if (corruptOneBlockGs && !corruptedGs) {
blockList.corruptBlockGSForTesting(i, rand);
LOG.info("Corrupted the GS for block ID " + i);
corruptedGs = true;
} else if (corruptOneBlockLen && !corruptedLen) {
blockList.corruptBlockLengthForTesting(i, rand);
LOG.info("Corrupted the length for block ID " + i);
corruptedLen = true;
} else {
break;
}
}
reports[reportIndex++] =
new StorageBlockReport(dnStorage, blockList.getBlockListAsLongs());
}
return reports;
}