devmadhuu commented on code in PR #11399:
URL: https://github.com/apache/ozone/pull/11399#discussion_r4403156232
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisUnderReplicationHandler.java:
##########
@@ -461,20 +466,39 @@ 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);
}
+ /**
+ * All Ratis replicas of a container are interchangeable, so the tier of any
+ * reported replica tells us where new copies belong.
+ *
+ * @return the storage type new replicas should use, or null when no replica
+ * reported one
+ */
+ private static StorageType targetStorageTypeFor(
+ List<ContainerReplica> replicas) {
+ return replicas.stream()
+ .map(ContainerReplica::getTargetStorageTypeForCopy)
+ .filter(Objects::nonNull)
+ .findFirst()
Review Comment:
You’re right: choosing the first non-null replica type does not establish
the intended target tier.
I propose using `ContainerInfo.getStorageTier()` when available. This is the
container’s allocated tier, including any creation-time fallback.
For legacy containers without a recorded tier, I suggest:
1. If the eligible replicas’ known types agree, use that type.
2. If they disagree, try their reported types in a deterministic order:
SCM’s configured default first if present among them, then the remaining types
sorted by name.
3. If no replica reports a type, explicitly use SCM’s configured default,
normally DISK.
So, with legacy SSD and DISK replicas and a DISK default, we would try DISK
first, then SSD if no valid DISK target exists. For a known recorded tier, we
would not introduce cross-tier fallback.
This defines a legacy repair policy; it does not claim to recover an unknown
original tier. What do you think ?
--
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]