@Override
  public boolean hasSameFaultDomains(String host1, String host2) {
    if (!hostToRackMap.keySet().contains(host1) || !hostToRackMap.keySet().contains(host2)) {
      hostToRackMap = computeHostToFaultDomainMap();
      hostToFaultDomainCacheUpdates.inc();
    }
    return hostToRackMap.get(host1).equals(hostToRackMap.get(host2));
  }
This method checks if the two hostnames provided reside on the same rack.
@param host1 hostname
@param host2 hostname
@return true if the hosts exist on the same rack
samza-yarn/src/main/java/org/apache/samza/job/yarn/YarnFaultDomainManager.java