List of usage examples for org.apache.hadoop.fs AbstractFileSystem getFileBlockLocations
public abstract BlockLocation[] getFileBlockLocations(final Path f, final long start, final long len) throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException;
From source file:com.cloudera.impala.catalog.TestLoadHdfsMetadataPerf.java
License:Apache License
/** * List file status by calling abstractFileSystem.listStatusIterator. *///from w w w . ja v a 2 s .c o m private static void listStatusIterator(String dirPath) { Path path = new Path(dirPath); boolean exceptionThrown = false; try { AbstractFileSystem fs = AbstractFileSystem.createFileSystem(path.toUri(), LoadMetadataUtil.getConf()); RemoteIterator<FileStatus> iter = fs.listStatusIterator(path); while (iter.hasNext()) { FileStatus fileStatus = iter.next(); BlockLocation[] locations = fs.getFileBlockLocations(fileStatus.getPath(), 0, fileStatus.getLen()); for (BlockLocation loc : locations) { loc.getNames(); loc.getHosts(); } } } catch (IOException e) { exceptionThrown = true; LOG.error("Failed to list Status Iterator", e); } assertFalse(exceptionThrown); }