void addReplicas(PartitionId partitionId, String dataCenterName, boolean attemptNonRackAwareOnFailure) {
    List<? extends ReplicaId> replicaIds = partitionId.getReplicaIds();
    Map<String, Integer> replicaCountByDatacenter = new HashMap<String, Integer>();
    long capacityOfReplicasInBytes = 0;
    // we ensure that the datacenter provided does not have any replicas
    for (ReplicaId replicaId : replicaIds) {
      if (replicaId.getDataNodeId().getDatacenterName().compareToIgnoreCase(dataCenterName) == 0) {
        throw new IllegalArgumentException(
            "Data center " + dataCenterName + " provided already contains replica for partition " + partitionId);
      }
      capacityOfReplicasInBytes = replicaId.getCapacityInBytes();
      int numberOfReplicas =
          replicaCountByDatacenter.getOrDefault(replicaId.getDataNodeId().getDatacenterName(), 0) + 1;
      replicaCountByDatacenter.put(replicaId.getDataNodeId().getDatacenterName(), numberOfReplicas);
    }
    if (replicaCountByDatacenter.size() == 0) {
      throw new IllegalArgumentException("No existing replicas present for partition " + partitionId + " in cluster.");
    }
    // verify that all data centers have the same replica
    int numberOfReplicasPerDatacenter = 0;
    int index = 0;
    for (Map.Entry<String, Integer> entry : replicaCountByDatacenter.entrySet()) {
      if (index == 0) {
        numberOfReplicasPerDatacenter = entry.getValue();
      }
      if (numberOfReplicasPerDatacenter != entry.getValue()) {
        throw new IllegalStateException("Datacenters have different replicas for partition " + partitionId);
      }
      index++;
    }
    Datacenter datacenterToAdd = hardwareLayout.findDatacenter(dataCenterName);
    List<Disk> disksForReplicas =
        allocateDisksForPartition(numberOfReplicasPerDatacenter, capacityOfReplicasInBytes, datacenterToAdd,
            attemptNonRackAwareOnFailure);
    partitionLayout.addNewReplicas((Partition) partitionId, disksForReplicas);
    System.out.println("Added partition " + partitionId + " to datacenter " + dataCenterName);
  }
Add a set of replicas on a new datacenter for an existing partition.

@param partitionId The partition to add to the new datacenter
@param dataCenterName The name of the new datacenter
@param attemptNonRackAwareOnFailure {@code true} if a non rack-aware allocation should be attempted if a rack-aware one
                           is not possible.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/StaticClusterManager.java