JSONObject toJSONObject() throws JSONException {
    JSONObject jsonObject = new JSONObject().put("hostname", hostname).put("port", portNum);
    addSSLPortToJson(jsonObject);
    jsonObject.putOpt("rackId", rackId);
    jsonObject.putOpt("xid", xid);
    jsonObject.put("hardwareState",
        dataNodeStatePolicy.isHardDown() ? HardwareState.UNAVAILABLE.name() : HardwareState.AVAILABLE.name())
        .put("disks", new JSONArray());
    for (Disk disk : disks) {
      jsonObject.accumulate("disks", disk.toJSONObject());
    }
    return jsonObject;
  }
Returns the {@link Port} of this node to connect to. A {@link Port} will be automatically selected based on if
there is a need of establishing an SSL connection.

@return {@link Port} to which the caller can connect to.
@throws IllegalStateException Thrown if an SSL connection is needed but no SSL port exists.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/DataNode.java