Skip to content

Commit

Permalink
IGNITE-24446 Implement utilities necessary for zone assignments calcu…
Browse files Browse the repository at this point in the history
…lation (#5200)
  • Loading branch information
ivanzlenko authored Feb 12, 2025
1 parent 63fb728 commit 6761ca9
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,35 @@ private static CompletableFuture<Map<Integer, Assignments>> zoneAssignments(
return numberOfMsPartitions == 0 ? Map.of() : result;
});
}

/**
* Returns zone pending assignments for all zone partitions from meta storage locally.
*
* @param metaStorageManager Meta storage manager.
* @param zoneId Zone id.
* @param numberOfPartitions Number of partitions.
* @param revision Revision.
* @return Future with zone assignments as a value.
*/
public static List<Assignments> zonePendingAssignmentsGetLocally(
MetaStorageManager metaStorageManager,
int zoneId,
int numberOfPartitions,
long revision
) {
return IntStream.range(0, numberOfPartitions)
.mapToObj(partitionId -> getLocalAssignments(metaStorageManager, zoneId, partitionId, revision))
.collect(toList());
}

private static @Nullable Assignments getLocalAssignments(
MetaStorageManager metaStorageManager,
int zoneId,
int partitionId,
long revision
) {
Entry entry = metaStorageManager.getLocally(pendingPartAssignmentsKey(new ZonePartitionId(zoneId, partitionId)), revision);

return entry != null ? Assignments.fromBytes(entry.value()) : null;
}
}
Loading

0 comments on commit 6761ca9

Please sign in to comment.