alex-plekhanov commented on a change in pull request #9539:
URL: https://github.com/apache/ignite/pull/9539#discussion_r751393929
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
##########
@@ -872,12 +1115,49 @@ private void finishCacheStart(UUID reqId, Map<UUID,
Boolean> res, Map<UUID, Exce
rollbackRestoreProc.start(reqId, reqId);
}
+ /**
+ * @param metas Map of snapshot metadata distribution across the cluster.
+ * @return Map of cache partitions per each node.
+ */
+ private static Map<UUID, Map<Integer, Set<Integer>>> snapshotAffinity(
+ Map<UUID, List<SnapshotMetadata>> metas,
+ BiPredicate<Integer, Integer> filter
+ ) {
+ Map<UUID, Map<Integer, Set<Integer>>> nodeToSnp = new HashMap<>();
+
+ for (Map.Entry<UUID, List<SnapshotMetadata>> e : metas.entrySet()) {
+ UUID nodeId = e.getKey();
+
+ for (SnapshotMetadata meta : ofNullable(e.getValue()).orElse(new
ArrayList<>())) {
+ Map<Integer, Set<Integer>> parts =
ofNullable(meta.partitions()).orElse(Collections.emptyMap());
+
+ for (Map.Entry<Integer, Set<Integer>> metaParts :
parts.entrySet()) {
+ for (Integer partId : metaParts.getValue()) {
+ if (filter.test(metaParts.getKey(), partId)) {
+ nodeToSnp.computeIfAbsent(nodeId, n -> new
HashMap<>())
+ .computeIfAbsent(metaParts.getKey(), k -> new
HashSet<>())
+ .add(partId);
+ }
+ }
+ }
+ }
+ }
+
+ List<UUID> list = new ArrayList<>(nodeToSnp.keySet());
+ Collections.shuffle(list);
Review comment:
Shuffle here has no effect since all required partitions are already
fetched from the first nodes in `metas`. Due to this load is not evenly
balanced.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
##########
@@ -872,12 +1118,49 @@ private void finishCacheStart(UUID reqId, Map<UUID,
Boolean> res, Map<UUID, Exce
rollbackRestoreProc.start(reqId, reqId);
}
+ /**
+ * @param metas Map of snapshot metadata distribution across the cluster.
+ * @return Map of cache partitions per each node.
+ */
+ private static Map<UUID, Map<Integer, Set<Integer>>> snapshotAffinity(
+ Map<UUID, ArrayList<SnapshotMetadata>> metas,
+ BiPredicate<Integer, Integer> filter
+ ) {
+ Map<UUID, Map<Integer, Set<Integer>>> nodeToSnp = new HashMap<>();
+
+ for (Map.Entry<UUID, ArrayList<SnapshotMetadata>> e :
metas.entrySet()) {
+ UUID nodeId = e.getKey();
+
+ for (SnapshotMetadata meta : ofNullable(e.getValue()).orElse(new
ArrayList<>())) {
Review comment:
No, it's not generalized by `Object` and can be used here without
problems
--
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]