CapMoon commented on PR #7754:
URL: https://github.com/apache/hadoop/pull/7754#issuecomment-4037974751
Great job, after further thinking, when check EC data in
`hasSufficientReplicas()`, we should considered the issue of duplicate indices
in Locations needs, like this:
```
private boolean hasSufficientReplicas(LocatedBlock block,
ErasureCodingPolicy ecPolicy) {
DatanodeInfo[] locations = block.getLocations();
if (locations == null || locations.length == 0) {
return false;
}
// Replicated block
if (!block.isStriped()) {
return true;
}
// Striped (EC) block
LocatedStripedBlock stripedBlock = (LocatedStripedBlock) block;
int requiredDataBlocks = (int) Math.min(ecPolicy.getNumDataUnits(),
(block.getBlockSize() - 1) / ecPolicy.getCellSize() + 1);
byte[] indices = stripedBlock.getBlockIndices();
boolean[] seen = new boolean[ecPolicy.getNumDataUnits() +
ecPolicy.getNumParityUnits()];
int count = 0;
for (byte idx : indices) {
int i = idx & 0xFF;
if (!seen[i]) {
seen[i] = true;
if (++count >= requiredDataBlocks) {
return true;
}
}
}
return false;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]