private Map<PriorityTier, Set<PartitionId>> assignPriorityTierToPartitions(Set<PartitionId> partitionIds, Map<PartitionId, Boolean> hasUpcomingDisruption) {
    Map<PriorityTier, Set<PartitionId>> result = new EnumMap<>(PriorityTier.class);
    // Initialize all priority categories with empty sets
    for (PriorityTier category : PriorityTier.values()) {
      result.put(category, new HashSet<>());
    }

    for (PartitionId partition : partitionIds) {
      int localReplicaCount = calculateLocalReplicaCount(partition);
      int minActiveReplica = getMinActiveReplicas(partition);
      boolean isBelowMinActiveReplica = false;
      boolean isAtMinActiveReplica = false;
      if (localReplicaCount < minActiveReplica) {
        isBelowMinActiveReplica = true;
      } else if (localReplicaCount == minActiveReplica) {
        isAtMinActiveReplica = true;
      }

      boolean hasDisruption = hasUpcomingDisruption.getOrDefault(partition, false);

      if (isBelowMinActiveReplica && hasDisruption) {
        result.get(PriorityTier.BELOW_MIN_REPLICA_WITH_DISRUPTION).add(partition);
        logger.info("High-priority partition {} with count below minActiveReplica and upcoming disruption",
            partition.toPathString());
      } else if (isBelowMinActiveReplica) {
        result.get(PriorityTier.BELOW_MIN_REPLICA_NO_DISRUPTION).add(partition);
        logger.info("High-priority partition {} with count below minActiveReplica",
            partition.toPathString());
      } else if (isAtMinActiveReplica && hasDisruption) {
        result.get(PriorityTier.MIN_REPLICA_WITH_DISRUPTION).add(partition);
        logger.info("High-priority partition {} with count at minActiveReplica and upcoming disruption",
            partition.toPathString());
      } else if (isAtMinActiveReplica) {
        result.get(PriorityTier.MIN_REPLICA_NO_DISRUPTION).add(partition);
        logger.info("High-priority partition {} with count at minActiveReplica",
            partition.toPathString());
      } else {
        result.get(PriorityTier.NORMAL).add(partition);
      }
    }

    return result;
  }
Assigns priority tiers to partitions based on their replica count and disruption status.

@param partitionIds Set of all partitions to evaluate
@param hasUpcomingDisruption Map of partitions to their disruption status
@return Map of priority categories to sets of partitions
ambry-prioritization/src/main/java/com/github/ambry/replica/prioritization/ReplicationPrioritizationManager.java