NamenodeJspHelper { static DatanodeDescriptor getRandomDatanode(final NameNode namenode) { return (DatanodeDescriptor)namenode.getNamesystem().getBlockManager( ).getDatanodeManager().getNetworkTopology().chooseRandom( NodeBase.ROOT); }    }
@Test(timeout = 15000) public void testGetRandomDatanode() { ImmutableSet<String> set = ImmutableSet.of(); NameNode nameNode = cluster.getNameNode(); ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (DataNode dataNode : cluster.getDataNodes()) { builder.add(dataNode.getDisplayName()); } set = builder.build(); for (int i = 0; i < 10; i++) { DatanodeDescriptor dnDescriptor = NamenodeJspHelper .getRandomDatanode(nameNode); assertTrue("testGetRandomDatanode error", set.contains(dnDescriptor.toString())); } }