private List<Disk> allocateDisksForPartition(int replicaCountPerDatacenter, long replicaCapacityInBytes,
      Datacenter datacenter, boolean attemptNonRackAwareOnFailure) {
    List<Disk> disks;
    if (datacenter.isRackAware()) {
      disks = getDiskCandidatesForPartition(replicaCountPerDatacenter, replicaCapacityInBytes, datacenter, true);
      if ((disks.size() < replicaCountPerDatacenter) && attemptNonRackAwareOnFailure) {
        System.err.println("Rack-aware allocation failed for a partition on datacenter:" + datacenter.getName()
            + "; attempting to perform a non rack-aware allocation.");
        disks = getDiskCandidatesForPartition(replicaCountPerDatacenter, replicaCapacityInBytes, datacenter, false);
      }
    } else if (!attemptNonRackAwareOnFailure) {
      throw new IllegalArgumentException(
          "attemptNonRackAwareOnFailure is false, but the datacenter: " + datacenter.getName()
              + " does not have rack information");
    } else {
      disks = getDiskCandidatesForPartition(replicaCountPerDatacenter, replicaCapacityInBytes, datacenter, false);
    }

    if (disks.size() < replicaCountPerDatacenter) {
      System.err.println(
          "Could only allocate " + disks.size() + "/" + replicaCountPerDatacenter + " replicas in datacenter: "
              + datacenter.getName());
    }
    return disks;
  }
Return a list of disks for a new partition in the specified {@link Datacenter}. Retry a non rack-aware allocation
in certain cases described below if {@code attemptNonRackAwareOnFailure} is enabled.

@param replicaCountPerDatacenter how many replicas to attempt to allocate in the datacenter
@param replicaCapacityInBytes the minimum amount of free space on a disk for a replica
@param datacenter the {@link Datacenter} to allocate replicas in
@param attemptNonRackAwareOnFailure {@code true} if we should attempt a non rack-aware allocation if a rack-aware
                                    one is not possible.
@return a list of {@code replicaCountPerDatacenter} or fewer disks that can be allocated for a new partition in
        the specified datacenter
ambry-clustermap/src/main/java/com/github/ambry/clustermap/StaticClusterManager.java