private int numReplicasForIdealState(String dcName, IdealState state) {
    if (isIdealStateInFullAuto(state)) {
      return Integer.valueOf(state.getReplicas());
    }
    int numReplicaToCompare = -1;
    String partitionToCompare = null;
    for (String partition : state.getPartitionSet()) {
      int replicaCount = state.getInstanceSet(partition).size();
      if (numReplicaToCompare == -1) {
        numReplicaToCompare = replicaCount;
        partitionToCompare = partition;
      } else {
        ensureOrThrow(numReplicaToCompare == replicaCount, "DC[" + dcName + "]: Resource " + state.getResourceName()
            + "'s partitions have different number of replicas, partition " + partitionToCompare + " has "
            + numReplicaToCompare + " replicas, but partition " + partition + " has " + replicaCount + " replicas");
      }
    }
    return numReplicaToCompare;
  }
Return a map from partition to resource id, given the map from resource id to ideal state.
@param resourceIdToIdealState
@return
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixBootstrapUpgradeUtil.java