@Override
  public List<ReplicaId> getPartitionListForDisk(DiskId diskId, int numberOfReplicasPerDisk) {
    lock.lock();
    LinkedHashSet<ReplicaId> replicaIdSet = diskIdToReplicaQueue.getOrDefault(diskId, new LinkedHashSet<>());
    List<ReplicaId> replicaIds = new ArrayList<>(replicaIdSet);

    List<ReplicaId> returnList = replicaIds.subList(0, Integer.min(numberOfReplicasPerDisk, replicaIds.size()));
    List<ReplicaId> remainingList = new ArrayList<>();

    if (returnList.size() < replicaIds.size()) {
      remainingList = replicaIds.subList(returnList.size(), replicaIds.size());
    }
    LinkedHashSet<ReplicaId> remainingSet = new LinkedHashSet<>(remainingList);

    diskIdToReplicaQueue.put(diskId, remainingSet);
    inProgressReplicas.addAll(returnList);
    lock.unlock();
    logger.info("Returning replicas for disk {} are {}", diskId, returnList);
    return returnList;
  }
Returns the partitions for disk by order of priority
and removes these from the queue , everytime different partitions get removed
@param diskId the {@link DiskId} for which the list of partitions should be replicated.
@param numberOfReplicasPerDisk the number of replicas that should be replicated from the given disk.
@return {@link List<ReplicaId>} replica ids for disk
ambry-prioritization/src/main/java/com/github/ambry/replica/prioritization/FileCopyDisruptionBasedPrioritizationManager.java