code: void resolveNetworkLocation(DatanodeInfo node) {
      List<String> names = new ArrayList<String>(1);
      if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
        // get the node's IP address
        names.add(node.getHost());
      } else if (dnsToSwitchMapping instanceof StaticMapping) {
        names.add(toHostPort(node));
      } else {
        // get the node's host name
        String hostName = node.getHostName();
        int colon = hostName.indexOf(":");
        hostName = (colon == -1) ? hostName : hostName.substring(0, colon);
        names.add(hostName);
      }
  
      // resolve its network location
      List<String> rName = dnsToSwitchMapping.resolve(names);
      String networkLocation;
      if (rName == null) {
        LOG.error("The resolve call returned null! Using " +
          NetworkTopology.DEFAULT_RACK + " for host " + names);
        networkLocation = NetworkTopology.DEFAULT_RACK;
      } else {
        networkLocation = rName.get(0);
      }
      node.setNetworkLocation(networkLocation);
    }
docs: /* Resolve a node's network location