private AmbryDisk getDiskForBootstrapReplica(AmbryDataNode dataNode, long replicaCapacity, String partitionName) {
    Set<AmbryDisk> disks = ambryDataNodeToAmbryDisks.get(dataNode);
    List<AmbryDisk> potentialDisks = new ArrayList<>();
    long maxAvailableDiskSpace = 0;
    for (AmbryDisk disk : disks) {
      if (disk.getState() == HardwareState.UNAVAILABLE) {
        continue;
      }
      if (disk.getAvailableSpaceInBytes() < replicaCapacity) {
        logger.info(
            "Disk {} doesn't have space to host new replica. Disk space left {}, replica capacity {}. Checking another disk",
            disk, disk.getAvailableSpaceInBytes(), replicaCapacity);
        continue;
      }
      if (disksAttemptedForBootstrap.containsKey(partitionName) && disksAttemptedForBootstrap.get(partitionName)
          .contains(disk)) {
        logger.info("Disk {} has already been tried before for this partition {}. Checking another disk", disk,
            partitionName);
        continue;
      }
      if (disk.getAvailableSpaceInBytes() == maxAvailableDiskSpace) {
        potentialDisks.add(disk);
      } else if (disk.getAvailableSpaceInBytes() > maxAvailableDiskSpace) {
        potentialDisks.clear();
        potentialDisks.add(disk);
        maxAvailableDiskSpace = disk.getAvailableSpaceInBytes();
      }
    }
    if (potentialDisks.isEmpty()) {
      logger.error("No disk space available to host new replica with capacity {}", replicaCapacity);
      return null;
    }

    // Select first available disk with maximum available capacity.
    return potentialDisks.get(0);
  }
Get a disk with maximum available space for bootstrapping replica in Full auto mode. This method is synchronized
since it can be queried concurrently when multiple replicas are bootstrapped.
@param dataNode        the {@link DataNodeId} on which disk is needed
@param replicaCapacity the capacity of the replica in bytes
@param partitionName partition name
@return {@link AmbryDisk} which has maximum available or free capacity. If none of the disks have free space,
returns null.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java