private void fillUptoBatchSize(int additionalPartitionsNeeded, Set<PartitionId> remainingPartitions) {
    int added = 0;
    for (PriorityTier priorityTier : PriorityTier.values()) {
      Set<PartitionId> partitions = prioritizedPartitions.get(priorityTier);
      if (!partitions.isEmpty()) {
        int toAdd = Math.min(additionalPartitionsNeeded - added, partitions.size());
        Set<PartitionId> partitionsToAdd = partitions.stream().filter(remainingPartitions::contains).limit(toAdd).collect(Collectors.toSet());

        // Record any newly added partitions
        if (!partitionsToAdd.isEmpty()) {
          replicationPrioritizationMetrics.recordPartitionsAddedToHighPriority(partitionsToAdd);
        }


        currentlyReplicatingPriorityPartitions.addAll(partitionsToAdd);

        added += partitionsToAdd.size();
        logger.info("Added {} partitions from {} category", partitionsToAdd.size(), priorityTier);

        if (added >= additionalPartitionsNeeded) {
          break;
        }
      }
    }
  }
Fill the currently replicating partitions up to the minimum batch size.
@param additionalPartitionsNeeded addition partitions needed
@param remainingPartitions remaining partitions to choose from
ambry-prioritization/src/main/java/com/github/ambry/replica/prioritization/ReplicationPrioritizationManager.java