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; }  DatanodeDescriptor getDatanodeByXferAddr(String ipAddr, int xferPort); @Override String toString();  }
@Test public void testContains() throws Exception { DatanodeDescriptor nodeNotInMap = DFSTestUtil.getDatanodeDescriptor("3.3.3.3", "/d1/r4"); for (DatanodeDescriptor dataNode : dataNodes) { assertTrue(map.contains(dataNode)); } assertFalse(map.contains(null)); assertFalse(map.contains(nodeNotInMap)); }