@Override // ClientProtocol public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { checkNNStartup(); metrics.incrGetBlockLocations(); return namesystem.getBlockLocations(getClientMachine(), src, offset, length); }
/** * Get block locations within the specified range. * @see ClientProtocol#getBlockLocations(String, long, long) */ public LocatedBlocks getBlockLocations(String src, long offset, long length ) throws IOException { return getBlockLocations(src, offset, length, false); }
/** * Get block locations within the specified range. */ public static LocatedBlocks getBlockLocations(NameNode namenode, String src, long offset, long length) throws IOException { return namenode.getNamesystem().getBlockLocations( src, offset, length, false, true); }
/** * Get block locations within the specified range. * * @see ClientProtocol#getBlockLocations(String, long, long) */ public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { INode[] inodes = dir.getExistingPathINodes(src); return getBlockLocations(src, inodes[inodes.length-1], offset, length, false, BlockMetaInfoType.NONE); }
/** {@inheritDoc} */ public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { myMetrics.numGetBlockLocations.inc(); return namesystem.getBlockLocations(getClientMachine(), src, offset, length, BlockMetaInfoType.NONE); }
public VersionedLocatedBlocks open(String src, long offset, long length) throws IOException { myMetrics.numGetBlockLocations.inc(); return (VersionedLocatedBlocks)namesystem.getBlockLocations( getClientMachine(), src, offset, length, BlockMetaInfoType.VERSION); }
public LocatedBlocksWithMetaInfo openAndFetchMetaInfo(String src, long offset, long length) throws IOException { myMetrics.numGetBlockLocations.inc(); return (LocatedBlocksWithMetaInfo)namesystem.getBlockLocations( getClientMachine(), src, offset, length, BlockMetaInfoType.VERSION_AND_NAMESPACEID); }
/** {@inheritDoc} */ public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { myMetrics.numGetBlockLocations.inc(); return namesystem.getBlockLocations(getClientMachine(), src, offset, length); }
/** * Get block locations within the specified range. */ public static LocatedBlocks getBlockLocations(NameNode namenode, String src, long offset, long length) throws IOException { return namenode.getNamesystem().getBlockLocations("foo", src, offset, length); }
@Override // ClientProtocol public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { checkNNStartup(); metrics.incrGetBlockLocations(); return namesystem.getBlockLocations(getClientMachine(), src, offset, length); }
@Override // ClientProtocol public LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException { checkNNStartup(); metrics.incrGetBlockLocations(); return namesystem.getBlockLocations(getClientMachine(), src, offset, length); }
private void checkForCorruptOpenFiles( FileStatus file, List<FileStatus> corruptFiles ) throws IOException { String filePath = file.getPath().toUri().getPath(); if (file.isDir()) { for (FileStatus fileStatus : nn.namesystem.dir.getListing(filePath)) { checkForCorruptOpenFiles(fileStatus, corruptFiles); } } else { LeaseManager.Lease lease = nn.getNamesystem().leaseManager.getLeaseByPath(filePath); // Condition: // 1. lease has expired hard limit // 2. the file is open for write // 3. the last block has 0 locations if (lease != null && lease.expiredHardLimit()) { LocatedBlocks blocks = nn.getNamesystem().getBlockLocations(filePath, 0, file.getLen()); List<LocatedBlock> locatedBlockList = blocks.getLocatedBlocks(); LocatedBlock lastBlock = locatedBlockList.get(locatedBlockList.size() - 1); if (blocks.isUnderConstruction() && lastBlock.getLocations().length == 0) { corruptFiles.add(file); } } } }
/** * Get block locations within the specified range. * * @see #getBlockLocations(String, long, long) */ LocatedBlocks getBlockLocations(String clientMachine, String src, long offset, long length) throws IOException { if (isPermissionEnabled) { checkPathAccess(src, FsAction.READ); } LocatedBlocks blocks = getBlockLocations(src, offset, length, true); if (blocks != null) { //sort the blocks DatanodeDescriptor client = host2DataNodeMap.getDatanodeByHost( clientMachine); for (LocatedBlock b : blocks.getLocatedBlocks()) { clusterMap.pseudoSortByDistance(client, b.getLocations()); } } return blocks; }
/** * Get block locations within the specified range. * * @see #getBlockLocations(String, long, long) */ LocatedBlocks getBlockLocations(String clientMachine, String src, long offset, long length, BlockMetaInfoType type) throws IOException { INode[] inodes = dir.getExistingPathINodes(src); if (isPermissionEnabled) { checkPathAccess(src, inodes, FsAction.READ); } LocatedBlocks blocks = getBlockLocations(src, inodes[inodes.length-1], offset, length, false, type); if (blocks != null) { //sort the blocks DatanodeDescriptor client = host2DataNodeMap.getDatanodeByHost( clientMachine); for (LocatedBlock b : blocks.getLocatedBlocks()) { clusterMap.pseudoSortByDistance(client, b.getLocations()); // Move decommissioned datanodes to the bottom Arrays.sort(b.getLocations(), DFSUtil.DECOM_COMPARATOR); } } return blocks; }
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithDelete() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { INodesInPath iip = fsd.getINodesInPath(FILE_PATH, true); FSDirDeleteOp.delete(fsd, iip, new INode.BlocksMapUpdateInfo(), new ArrayList<INode>(), now()); invocation.callRealMethod(); return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog, never()).logTimes(anyString(), anyLong(), anyLong()); fsn.close(); }
@Test(timeout = 30000) public void testResolveReservedPath() throws IOException { FSNamesystem fsn = setupFileSystem(); FSEditLog editlog = fsn.getEditLog(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(FILE_PATH), anyLong(), anyLong()); fsn.close(); }
when(fsName.getBlockLocations(any(FSPermissionChecker.class), anyString(), anyLong(), anyLong(), anyBoolean(), anyBoolean()))
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithRename() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); final String DST_PATH = "/bar"; final boolean[] renamed = new boolean[1]; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { invocation.callRealMethod(); if (!renamed[0]) { FSDirRenameOp.renameTo(fsd, fsd.getPermissionChecker(), FILE_PATH, DST_PATH, new INode.BlocksMapUpdateInfo(), false); renamed[0] = true; } return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(DST_PATH), anyLong(), anyLong()); fsn.close(); }
try { checkOperation(OperationCategory.READ); res = getBlockLocations(pc, srcArg, offset, length, true, true); } catch (AccessControlException e) { logAuditEvent(false, operationName, srcArg);
try { checkOperation(OperationCategory.READ); res = getBlockLocations(pc, srcArg, offset, length, true, true); } catch (AccessControlException e) { logAuditEvent(false, operationName, srcArg);