code: public boolean isInLocalRack(InetSocketAddress addr) {
      if (dnsToSwitchMapping == null || this.localhostNetworkLocation == null) {
        return false;
      }
      ArrayList<String> tempList = new ArrayList<String>();
      tempList.add(addr.getAddress().getHostAddress());
      List<String> retList = dnsToSwitchMapping.resolve(tempList);
      if (retList != null && retList.size() > 0) {
        return retList.get(0).equals(this.localhostNetworkLocation);
      } else {
        return false;
      }
    }
docs: Determine whether the input address is in the same rack as local machine