@Override
  public Port getPortToConnectTo() {
    if (clusterMapConfig.clusterMapEnableHttp2Replication) {
      if (ports.containsKey(PortType.HTTP2)) {
        return ports.get(PortType.HTTP2);
      } else {
        throw new IllegalStateException("No HTTP2 Port exists for the data node " + hostname + ":" + portNum);
      }
    }
    if (sslEnabledDataCenters.contains(datacenter.getName())) {
      if (ports.containsKey(PortType.SSL)) {
        return ports.get(PortType.SSL);
      } else {
        throw new IllegalStateException("No SSL Port exists for the data node " + hostname + ":" + portNum);
      }
    }
    return ports.get(PortType.PLAINTEXT);
  }
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