devmadhuu commented on code in PR #12185:
URL: https://github.com/apache/ozone/pull/12185#discussion_r4757001902
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ECUnderReplicationHandler.java:
##########
@@ -699,21 +700,66 @@ private int processMaintenanceOnlyIndexes(
private void createReplicateCommand(
ContainerInfo container, Iterator<DatanodeDetails> iterator,
- ContainerReplica replica, ECContainerReplicaCount replicaCount)
+ ContainerReplica replica, ECContainerReplicaCount replicaCount,
StorageType targetStorageType)
throws CommandTargetOverloadedException, NotLeaderException {
DatanodeDetails source = replica.getDatanodeDetails();
DatanodeDetails target = iterator.next();
replicationManager.sendThrottledReplicationCommand(
container, Collections.singletonList(source), target,
- replica.getReplicaIndex());
- adjustPendingOps(replicaCount, target, replica.getReplicaIndex());
+ replica.getReplicaIndex(), targetStorageType);
+ adjustPendingOps(replicaCount, target, replica.getReplicaIndex(),
targetStorageType);
}
private void adjustPendingOps(ECContainerReplicaCount replicaCount,
- DatanodeDetails target, int replicaIndex) {
+ DatanodeDetails target, int replicaIndex,
StorageType targetStorageType) {
replicaCount.addPendingOp(new ContainerReplicaOp(
ContainerReplicaOp.PendingOpType.ADD, target, replicaIndex, null,
- Long.MAX_VALUE, 0, null));
+ Long.MAX_VALUE, 0, targetStorageType));
+ }
+
+ /**
+ * Selects copy targets of the container's storage tier, falling back the
same way RATIS repair does: on
+ * FAILED_TO_FIND_SUITABLE_NODE, retry with {@link
ReplicationManagerUtil#getFallbackStorageType} (SSD to DISK;
+ * others have no fallback). A container with no tier resolves to {@link
StorageType#DEFAULT}.
+ */
+ private TargetSelection selectCopyTargetsWithFallback(ContainerInfo
container, int requiredNodes,
Review Comment:
Done — extracted the fallback target-selection into `ReplicationManagerUtil`:
- New ReplicationManagerUtil.selectTargetsWithFallback(preferredStorageType,
TargetSelector) + the TargetSelector functional interface and the
TargetSelection result type (lifted from the RATIS handler, which had the
cleanest shape). It tries the container's tier, and on
FAILED_TO_FIND_SUITABLE_NODE retries once with getFallbackStorageType
(SSD→DISK; others none), rethrowing when there's no fallback or the fallback
also finds nothing.
- All three under-replication handlers now call it with their own selector
lambda, and their duplicated logic is gone: RatisUnderReplicationHandler (its
private method + TargetSelector/TargetSelection inner classes removed),
ECUnderReplicationHandler (its selectCopyTargetsWithFallback + TargetSelection
removed), and QuasiClosedStuckUnderReplicationHandler (its inline nested
try/catch replaced).
--
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]