umamaheswararao commented on code in PR #3984:
URL: https://github.com/apache/ozone/pull/3984#discussion_r1029618732
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ECUnderReplicationHandler.java:
##########
@@ -158,96 +169,63 @@ public Map<DatanodeDetails, SCMCommand<?>>
processAndCreateCommands(
final ContainerID id = container.containerID();
final Map<DatanodeDetails, SCMCommand<?>> commands = new HashMap<>();
try {
- // State is UNDER_REPLICATED
final List<DatanodeDetails> deletionInFlight = new ArrayList<>();
for (ContainerReplicaOp op : pendingOps) {
if (op.getOpType() == ContainerReplicaOp.PendingOpType.DELETE) {
deletionInFlight.add(op.getTarget());
}
}
- List<Integer> missingIndexes = replicaCount.unavailableIndexes(true);
- Map<Integer, Pair<ContainerReplica, NodeStatus>> sources =
- filterSources(replicas, deletionInFlight);
- List<DatanodeDetails> nodes =
- sources.values().stream().map(Pair::getLeft)
- .map(ContainerReplica::getDatanodeDetails)
- .filter(datanodeDetails ->
- datanodeDetails.getPersistedOpState() ==
- HddsProtos.NodeOperationalState.IN_SERVICE)
- .collect(Collectors.toList());
- // We got the missing indexes, this is excluded any decommissioning
- // indexes. Find the good source nodes.
- if (missingIndexes.size() > 0) {
- LOG.debug("Missing indexes detected for the container {}." +
- " The missing indexes are {}", id, missingIndexes);
- // We have source nodes.
- if (sources.size() >= repConfig.getData()) {
- final List<DatanodeDetails> selectedDatanodes = getTargetDatanodes(
- excludedNodes, container, missingIndexes.size());
-
- if (validatePlacement(nodes, selectedDatanodes)) {
- excludedNodes.addAll(selectedDatanodes);
- nodes.addAll(selectedDatanodes);
- List<ReconstructECContainersCommand.DatanodeDetailsAndReplicaIndex>
- sourceDatanodesWithIndex = new ArrayList<>();
- for (Pair<ContainerReplica, NodeStatus> src : sources.values()) {
- sourceDatanodesWithIndex.add(
- new ReconstructECContainersCommand
- .DatanodeDetailsAndReplicaIndex(
- src.getLeft().getDatanodeDetails(),
- src.getLeft().getReplicaIndex()));
- }
+ Map<Integer, Pair<ContainerReplica, NodeStatus>> sources =
+ filterSources(replicas, deletionInFlight);
+ List<DatanodeDetails> availableSourceNodes =
+ sources.values().stream().map(Pair::getLeft)
+ .map(ContainerReplica::getDatanodeDetails)
+ .filter(datanodeDetails ->
+ datanodeDetails.getPersistedOpState() ==
+ HddsProtos.NodeOperationalState.IN_SERVICE)
+ .collect(Collectors.toList());
- final ReconstructECContainersCommand reconstructionCommand =
- new
ReconstructECContainersCommand(id.getProtobuf().getId(),
- sourceDatanodesWithIndex, selectedDatanodes,
- int2byte(missingIndexes),
- repConfig);
- // Keeping the first target node as coordinator.
- commands.put(selectedDatanodes.get(0), reconstructionCommand);
- }
- } else {
- LOG.warn("Cannot proceed for EC container reconstruction for {}, due"
- + " to insufficient source replicas found. Number of source "
- + "replicas needed: {}. Number of available source replicas are:"
- + " {}. Available sources are: {}", container.containerID(),
- repConfig.getData(), sources.size(), sources);
+ try {
+ processMissingIndexes(replicaCount, sources, availableSourceNodes,
+ excludedNodes, commands);
+ processDecommissioningIndexes(replicaCount, replicas,
+ availableSourceNodes, excludedNodes, commands);
+ processMaintenanceOnlyIndexes(replicaCount, replicas, excludedNodes,
+ commands);
+ // TODO - we should be able to catch SCMException here and check the
+ // result code but the RackAware topology never sets the code.
+ } catch (CannotFindTargetsException e) {
+ // If we get here, we tried to find nodes to fix the under replication
Review Comment:
Got it. Anyway even if they both scheduled at same, they both mostly of
different index, so that should not create any harm I beleive.
--
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]