|
@@ -1165,13 +1165,14 @@ public class BlockManager {
|
|
DatanodeStorageInfo storageInfo,
|
|
DatanodeStorageInfo storageInfo,
|
|
DatanodeDescriptor node) throws IOException {
|
|
DatanodeDescriptor node) throws IOException {
|
|
|
|
|
|
- BlockCollection bc = b.corrupted.getBlockCollection();
|
|
|
|
- if (bc == null) {
|
|
|
|
|
|
+ if (b.corrupted.isDeleted()) {
|
|
blockLog.info("BLOCK markBlockAsCorrupt: {} cannot be marked as" +
|
|
blockLog.info("BLOCK markBlockAsCorrupt: {} cannot be marked as" +
|
|
" corrupt as it does not belong to any file", b);
|
|
" corrupt as it does not belong to any file", b);
|
|
addToInvalidates(b.corrupted, node);
|
|
addToInvalidates(b.corrupted, node);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ short expectedReplicas =
|
|
|
|
+ b.corrupted.getBlockCollection().getBlockReplication();
|
|
|
|
|
|
// Add replica to the data-node if it is not already there
|
|
// Add replica to the data-node if it is not already there
|
|
if (storageInfo != null) {
|
|
if (storageInfo != null) {
|
|
@@ -1183,13 +1184,13 @@ public class BlockManager {
|
|
b.reasonCode);
|
|
b.reasonCode);
|
|
|
|
|
|
NumberReplicas numberOfReplicas = countNodes(b.stored);
|
|
NumberReplicas numberOfReplicas = countNodes(b.stored);
|
|
- boolean hasEnoughLiveReplicas = numberOfReplicas.liveReplicas() >= bc
|
|
|
|
- .getBlockReplication();
|
|
|
|
|
|
+ boolean hasEnoughLiveReplicas = numberOfReplicas.liveReplicas() >=
|
|
|
|
+ expectedReplicas;
|
|
boolean minReplicationSatisfied =
|
|
boolean minReplicationSatisfied =
|
|
numberOfReplicas.liveReplicas() >= minReplication;
|
|
numberOfReplicas.liveReplicas() >= minReplication;
|
|
boolean hasMoreCorruptReplicas = minReplicationSatisfied &&
|
|
boolean hasMoreCorruptReplicas = minReplicationSatisfied &&
|
|
(numberOfReplicas.liveReplicas() + numberOfReplicas.corruptReplicas()) >
|
|
(numberOfReplicas.liveReplicas() + numberOfReplicas.corruptReplicas()) >
|
|
- bc.getBlockReplication();
|
|
|
|
|
|
+ expectedReplicas;
|
|
boolean corruptedDuringWrite = minReplicationSatisfied &&
|
|
boolean corruptedDuringWrite = minReplicationSatisfied &&
|
|
(b.stored.getGenerationStamp() > b.corrupted.getGenerationStamp());
|
|
(b.stored.getGenerationStamp() > b.corrupted.getGenerationStamp());
|
|
// case 1: have enough number of live replicas
|
|
// case 1: have enough number of live replicas
|
|
@@ -2512,7 +2513,7 @@ public class BlockManager {
|
|
} else {
|
|
} else {
|
|
storedBlock = block;
|
|
storedBlock = block;
|
|
}
|
|
}
|
|
- if (storedBlock == null || storedBlock.getBlockCollection() == null) {
|
|
|
|
|
|
+ if (storedBlock == null || storedBlock.isDeleted()) {
|
|
// If this block does not belong to anyfile, then we are done.
|
|
// If this block does not belong to anyfile, then we are done.
|
|
blockLog.info("BLOCK* addStoredBlock: {} on {} size {} but it does not" +
|
|
blockLog.info("BLOCK* addStoredBlock: {} on {} size {} but it does not" +
|
|
" belong to any file", block, node, block.getNumBytes());
|
|
" belong to any file", block, node, block.getNumBytes());
|
|
@@ -2797,8 +2798,7 @@ public class BlockManager {
|
|
* what happened with it.
|
|
* what happened with it.
|
|
*/
|
|
*/
|
|
private MisReplicationResult processMisReplicatedBlock(BlockInfoContiguous block) {
|
|
private MisReplicationResult processMisReplicatedBlock(BlockInfoContiguous block) {
|
|
- BlockCollection bc = block.getBlockCollection();
|
|
|
|
- if (bc == null) {
|
|
|
|
|
|
+ if (block.isDeleted()) {
|
|
// block does not belong to any file
|
|
// block does not belong to any file
|
|
addToInvalidates(block);
|
|
addToInvalidates(block);
|
|
return MisReplicationResult.INVALID;
|
|
return MisReplicationResult.INVALID;
|
|
@@ -2809,7 +2809,8 @@ public class BlockManager {
|
|
return MisReplicationResult.UNDER_CONSTRUCTION;
|
|
return MisReplicationResult.UNDER_CONSTRUCTION;
|
|
}
|
|
}
|
|
// calculate current replication
|
|
// calculate current replication
|
|
- short expectedReplication = bc.getBlockReplication();
|
|
|
|
|
|
+ short expectedReplication =
|
|
|
|
+ block.getBlockCollection().getBlockReplication();
|
|
NumberReplicas num = countNodes(block);
|
|
NumberReplicas num = countNodes(block);
|
|
int numCurrentReplica = num.liveReplicas();
|
|
int numCurrentReplica = num.liveReplicas();
|
|
// add to under-replicated queue if need to be
|
|
// add to under-replicated queue if need to be
|