HDFSFileFinder extends Configured implements Tool { public Map<String,Long> getNumBytesOfGlobHeldByDatanodes(Path p) throws IOException { return getNumBytesOfGlobHeldByDatanodes(p, getConf()); }  Map<String,Long> getNumBytesOfGlobHeldByDatanodes(Path p); static Map<String,Long> getNumBytesOfGlobHeldByDatanodes(Path p, Configuration conf); @Override int run(String[] args); static void main(String[] args);  }
@Test public void testFileFinder() throws Exception { File tmpFile = File.createTempFile("test-file", ".txt"); PrintWriter pw = new PrintWriter(tmpFile); pw.println("test file data"); pw.flush(); pw.close(); tmpFile.deleteOnExit(); Path src = new Path(tmpFile.getAbsolutePath()); Path dst = new Path("test-file.txt"); fs.copyFromLocalFile(src, dst); Map<String, Long> bytesHeld = HDFSFileFinder.getNumBytesOfGlobHeldByDatanodes(dst, conf); for (String node : bytesHeld.keySet()) LOG.info(node + " : " + bytesHeld.get(node)); assertTrue(replicationFactor <= bytesHeld.keySet().size()); }