private void ensurePartitionAbsenceOnNodeAndValidateCapacity(AmbryPartition partition, AmbryDataNode datanode,
        long expectedReplicaCapacity) {
      for (AmbryReplica replica : ambryPartitionToAmbryReplicas.get(partition)) {
        if (replica.getDataNodeId().equals(datanode)) {
          throw new IllegalStateException("Replica already exists on " + datanode + " for " + partition);
        } else if (replica.getCapacityInBytes() != expectedReplicaCapacity) {
          throw new IllegalStateException("Expected replica capacity " + expectedReplicaCapacity + " is different from "
              + "the capacity of an existing replica " + replica.getCapacityInBytes());
        }
      }
    }
Ensure that the given partition is absent on the given datanode. This is called as part of an inline validation
done to ensure that two replicas of the same partition do not exist on the same datanode.
@param partition the {@link AmbryPartition} to check.
@param datanode the {@link AmbryDataNode} on which to check.
@param expectedReplicaCapacity the capacity expected for the replicas of the partition.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java