class Host2NodesMap {

  boolean contains(DatanodeDescriptor node) {
    if (node == null) {
      return false;
    }

    String ipAddr = node.getIpAddr();
    hostmapLock.readLock().lock();
    try {
      DatanodeDescriptor[] nodes = map.get(ipAddr);
      if (nodes != null) {
        for (DatanodeDescriptor containedNode : nodes) {
          if (node == containedNode) {
            return true;
          }
        }
      }
    } finally {
      hostmapLock.readLock().unlock();
    }
    return false;
  }

}