public static int getDataNodePort(Configuration conf) {
    HdfsConfiguration.init();
    Configuration dnConf = new HdfsConfiguration(conf);
    int dnPort = NetUtils.createSocketAddr(dnConf.get(DFSConfigKeys.DFS_DATANODE_ADDRESS_KEY,
      DFSConfigKeys.DFS_DATANODE_ADDRESS_DEFAULT)).getPort();
    LOG.debug("Loaded default datanode port for FN: {}", dnPort);
    return dnPort;
  }
Get the rack of server from local mapping when present, saves lookup by the RackManager.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java