public DataNode findDataNode(String hostname, int port) {
    String canonicalHostname =
        clusterMapConfig.clusterMapResolveHostnames ? ClusterMapUtils.getFullyQualifiedDomainName(hostname) : hostname;
    logger.trace("host to find host {} port {}", canonicalHostname, port);
    for (Datacenter datacenter : datacenters) {
      logger.trace("datacenter {}", datacenter.getName());
      for (DataNode dataNode : datacenter.getDataNodes()) {
        if (dataNode.getHostname().equals(canonicalHostname) && (dataNode.getPort() == port)) {
          return dataNode;
        }
      }
    }
    return null;
  }
Finds DataNode by hostname and port. Note that hostname is converted to canonical hostname for comparison.

@param hostname of datanode
@param port of datanode
@return DataNode or null if not found.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HardwareLayout.java