fat-catTW commented on code in PR #12063:
URL: https://github.com/apache/ozone/pull/12063#discussion_r4683369764


##########
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:
   Updated.
   Changed the fallback mapping to explicitly use SSD → DISK, with no fallback 
for other types. I also added tests for DISK and containers without a storage 
tier.



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