JSONObject toJSONObject() throws JSONException {
    JSONObject jsonObject = new JSONObject().put("name", name).put("id", id).put("dataNodes", new JSONArray());
    for (DataNode dataNode : dataNodes) {
      jsonObject.accumulate("dataNodes", dataNode.toJSONObject());
    }
    return jsonObject;
  }
A datacenter can be marked as rack-aware if all nodes have defined rack IDs. This method throws an exception
if some nodes have rack IDs and some do not.  It also sets the {@code rackAware} flag to {@code true} if all
nodes have rack IDs.

@throws IllegalStateException if some nodes have defined rack IDs and some do not.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/Datacenter.java