devmadhuu commented on code in PR #12063:
URL: https://github.com/apache/ozone/pull/12063#discussion_r4666449823


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisUnderReplicationHandler.java:
##########
@@ -461,20 +464,72 @@ private List<DatanodeDetails> getTargets(
 
     LOG.debug("UsedList: {}, size {}. ExcludeList: {}, size: {}. ",
         used, used.size(), excluded, excluded.size());
-    // TODO StoragePolicy replace this StorageType with container actual 
StorageType
     return ReplicationManagerUtil.getTargetDatanodes(placementPolicy,
         replicaCount.additionalReplicaNeeded(), used, excluded,
-        currentContainerSize, replicaCount.getContainer(), 
StorageType.DEFAULT);
+        currentContainerSize, replicaCount.getContainer(), targetStorageType);
+  }
+
+  private List<DatanodeDetails> getTargets(ContainerInfo container,
+      ReplicationManagerUtil.ExcludedAndUsedNodes excludedAndUsedNodes, 
StorageType targetStorageType)
+      throws SCMException {
+    return ReplicationManagerUtil.getTargetDatanodes(placementPolicy, 1, 
excludedAndUsedNodes.getUsedNodes(),
+        excludedAndUsedNodes.getExcludedNodes(), currentContainerSize, 
container, targetStorageType);
+  }
+
+  private TargetSelection selectTargetsWithFallback(StorageType 
preferredStorageType, TargetSelector selector)
+      throws SCMException {
+    try {
+      return new TargetSelection(selector.select(preferredStorageType), 
preferredStorageType);
+    } catch (SCMException e) {
+      if (e.getResult() != 
SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE) {
+        throw e;
+      }
+      StorageType fallbackStorageType = 
getFallbackStorageType(preferredStorageType);
+      if (fallbackStorageType == null) {
+        throw e;
+      }
+      List<DatanodeDetails> targets = selector.select(fallbackStorageType);
+      if (targets.isEmpty()) {
+        throw e;
+      }
+      return new TargetSelection(targets, fallbackStorageType);
+    }
+  }
+
+  private static StorageType getFallbackStorageType(StorageType storageType) {

Review Comment:
   nit: this finds the fallback by scanning OzoneStoragePolicy for the first 
policy whose creation tier matches.
   It works for HOT/WARM/COLD, but depends on each creation tier being unique 
and on enum order. Could we make the
   mapping explicit (SSD -> DISK, others none), or add a comment that it relies 
on unique creation tiers? Also
   worth a small test that a DISK/WARM container and a no-tier container do not 
fall back.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/QuasiClosedStuckUnderReplicationHandler.java:
##########
@@ -101,12 +101,13 @@ public int processAndSendCommands(Set<ContainerReplica> 
replicas, List<Container
     int totalRequiredReplicas = 0;
     int totalCommandsSent = 0;
     IOException firstException = null;
+    StorageType targetStorageType = 
ReplicationManagerUtil.getTargetStorageType(containerInfo);

Review Comment:
   Thanks for adding the fallback for Ratis under replication handler. The same 
issue applies here as well: this handler uses only the container tier, so a 
quasi-closed stuck SSD container stays under-replicated when no SSD target is 
free. That includes a
   replica on a decommissioning node, so decommission waits. Before this PR it 
was repaired on DISK. Could we use
   the same SSD -> DISK retry here and send the chosen type in the command, 
with a test like
   `testUnderReplicationFallsBackToDiskWhenSsdIsUnavailable`?



-- 
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]

Reply via email to