ZanderXu commented on code in PR #7754:
URL: https://github.com/apache/hadoop/pull/7754#discussion_r3136421721
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java:
##########
@@ -9206,16 +9197,75 @@ private boolean isObserver() {
return haEnabled && haContext != null &&
haContext.getState().getServiceState() == OBSERVER;
}
+ private boolean hasSufficientReplicas(LocatedBlock block,
+ ErasureCodingPolicy ecPolicy) {
+ DatanodeInfo[] locations = block.getLocations();
+ if (locations == null) {
+ return false;
+ }
+
+ if (block.isStriped()) {
+ LocatedStripedBlock stripedBlock = (LocatedStripedBlock) block;
Review Comment:
```
LocatedStripedBlock stripedBlock = (LocatedStripedBlock) block;
// For erasure coded files, require enough data units to reconstruct
// the block, bounded by the number of cells in the block.
long numCells = (block.getBlockSize() - 1) / ecPolicy.getCellSize() +
1;
int minRequiredIndices = (int) Math.min(ecPolicy.getNumDataUnits(),
numCells);
// Units can be over-replicated, so need to account for unique indices
byte[] blockIndices = stripedBlock.getBlockIndices();
boolean[] seenIndices = new boolean[ecPolicy.getNumDataUnits() +
ecPolicy.getNumParityUnits()];
int uniqueIndexCount = 0;
for (byte idx : blockIndices) {
int index = idx & 0xFF;
if (!seenIndices[index]) {
seenIndices[index] = true;
if (++uniqueIndexCount >= minRequiredIndices) {
return true;
}
}
}
return false;
```
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java:
##########
@@ -9206,16 +9197,75 @@ private boolean isObserver() {
return haEnabled && haContext != null &&
haContext.getState().getServiceState() == OBSERVER;
}
+ private boolean hasSufficientReplicas(LocatedBlock block,
Review Comment:
hasSufficientBlockLocations
--
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]