@VisibleForTesting public LocatedBlocks getLocatedBlocks(String src, long start, long length) throws IOException { try (TraceScope ignored = newPathTraceScope("getBlockLocations", src)) { return callGetBlockLocations(namenode, src, start, length); } }
public LocatedBlocks getLocatedBlocks(String src, long start, long length) throws IOException { return callGetBlockLocations(namenode, src, start, length, isMetaInfoSuppoted(namenodeProtocolProxy)); }
public static LocatedBlocks callGetBlockLocations(ClientProtocol namenode, String src, long start, long length) throws IOException { return DFSClient.callGetBlockLocations(namenode, src, start, length); }
protected LocatedBlocks getBlockLocations(String src, long length) throws IOException { //get block locations for the file range LocatedBlocks blockLocations = callGetBlockLocations(namenode, src, 0, length); if (null == blockLocations) { throw new FileNotFoundException("File does not exist: " + src); } if (blockLocations.isUnderConstruction()) { throw new IOException("Fail to get checksum, since file " + src + " is under construction."); } return blockLocations; }
@VisibleForTesting public LocatedBlocks getLocatedBlocks(String src, long start, long length) throws IOException { TraceScope scope = getPathTraceScope("getBlockLocations", src); try { return callGetBlockLocations(namenode, src, start, length); } finally { scope.close(); } }
/** * Get block location info about file * * getBlockLocations() returns a list of hostnames that store * data for a specific file region. It returns a set of hostnames * for every block within the indicated region. * * This function is very useful when writing code that considers * data-placement when performing operations. For example, the * MapReduce system tries to schedule tasks on the same machines * as the data-block the task processes. */ public BlockLocation[] getBlockLocations(String src, long start, long length) throws IOException { LocatedBlocks blocks = callGetBlockLocations(namenode, src, start, length, isMetaInfoSuppoted(namenodeProtocolProxy)); return DFSUtil.locatedBlocks2Locations(blocks); }
@VisibleForTesting public LocatedBlocks getLocatedBlocks(String src, long start, long length) throws IOException { TraceScope scope = getPathTraceScope("getBlockLocations", src); try { return callGetBlockLocations(namenode, src, start, length); } finally { scope.close(); } }
do { Thread.sleep(SHORT_LEASE_PERIOD); locatedBlocks = DFSClient.callGetBlockLocations(dfs.dfs.namenode, filestr, 0L, size); } while (locatedBlocks.isUnderConstruction());
= callGetBlockLocations(namenode, src, 0, Long.MAX_VALUE).getLocatedBlocks(); final DataOutputBuffer md5out = new DataOutputBuffer(); int bytesPerCRC = 0;
) throws IOException { final LocatedBlocks locatedBlocks = callGetBlockLocations( namenode, src, 0, Long.MAX_VALUE, isMetaInfoSuppoted(namenodeProxy)); int namespaceId = 0;
Preconditions.checkArgument(length >= 0); LocatedBlocks blockLocations = callGetBlockLocations(namenode, src, 0, length); if (null == blockLocations) { blockLocations = callGetBlockLocations(namenode, src, 0, length); if (null == blockLocations) { throw new FileNotFoundException("File does not exist: " + src);
final List<LocatedBlock> locatedblocks = DFSClient.callGetBlockLocations( cluster.getNameNode(), f, 0, Long.MAX_VALUE).getLocatedBlocks(); final DatanodeInfo first = locatedblocks.get(0).getLocations()[0];
LocatedBlocks blocks = callGetBlockLocations(namenode, src, start, length); if (blocks == null) { return new BlockLocation[0];
Preconditions.checkArgument(length >= 0); LocatedBlocks blockLocations = callGetBlockLocations(namenode, src, 0, length); if (null == blockLocations) { blockLocations = callGetBlockLocations(namenode, src, 0, length); if (null == blockLocations) { throw new FileNotFoundException("File does not exist: " + src);
@Test public void testGetFileChecksum() throws Exception { final String f = "/testGetFileChecksum"; final Path p = new Path(f); final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build(); try { cluster.waitActive(); //create a file final FileSystem fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, p, 1L << 20, (short)3, 20100402L); //get checksum final FileChecksum cs1 = fs.getFileChecksum(p); assertTrue(cs1 != null); //stop the first datanode final List<LocatedBlock> locatedblocks = DFSClient.callGetBlockLocations( cluster.getNameNodeRpc(), f, 0, Long.MAX_VALUE) .getLocatedBlocks(); final DatanodeInfo first = locatedblocks.get(0).getLocations()[0]; cluster.stopDataNode(first.getXferAddr()); //get checksum again final FileChecksum cs2 = fs.getFileChecksum(p); assertEquals(cs1, cs2); } finally { cluster.shutdown(); } }