/** * 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); }
/** * Delete a path from the name space * Update the count at each ancestor directory with quota * @param src a string representation of a path to an inode * @param modificationTime the time the inode is removed * @return the deleted target inode, null if deletion failed */ INode unprotectedDelete(String src, long modificationTime) { return unprotectedDelete(src, this.getExistingPathINodes(src), null, BLOCK_DELETION_NO_LIMIT, modificationTime); }
private void getListingCheck(String src) throws IOException { getListingCheck(src, dir.getExistingPathINodes(src)); }
private void verifyParentDir(String src) throws FileAlreadyExistsException, FileNotFoundException { Path parent = new Path(src).getParent(); if (parent != null) { INode[] pathINodes = dir.getExistingPathINodes(parent.toString()); if (pathINodes[pathINodes.length - 1] == null) { throw new FileNotFoundException("Parent directory doesn't exist: " + parent.toString()); } else if (!pathINodes[pathINodes.length - 1].isDirectory()) { throw new FileAlreadyExistsException("Parent path is not a directory: " + parent.toString()); } } }
long getPreferredBlockSize(String filename) throws IOException { if (isPermissionEnabled) { INode[] inodes = dir.getExistingPathINodes(filename); checkTraverse(filename, inodes); } return dir.getPreferredBlockSize(filename); }
private INodeDirectory getParentINodeDirectory(byte[][] pathComponents ) throws FileNotFoundException, PathIsNotDirectoryException, UnresolvedLinkException { if (pathComponents.length < 2) { // root return null; } // Gets the parent INode final INodesInPath inodes = namesystem.dir.getExistingPathINodes( pathComponents); return INodeDirectory.valueOf(inodes.getINode(-2), pathComponents); }
private INodeDirectory getParentINodeDirectory(byte[][] pathComponents ) throws FileNotFoundException, PathIsNotDirectoryException, UnresolvedLinkException { if (pathComponents.length < 2) { // root return null; } // Gets the parent INode final INodesInPath inodes = namesystem.dir.getExistingPathINodes( pathComponents); return INodeDirectory.valueOf(inodes.getINode(-2), pathComponents); }
/** * Get the file info for a specific file. * * @param src The string representation of the path to the file * @return object containing information regarding the file * or null if file not found * @throws IOException if permission to access file is denied by the system */ HdfsFileStatus getHdfsFileInfo(String src) throws IOException { if (isPermissionEnabled) { INode[] inodes = dir.getExistingPathINodes(src); checkTraverse(src, inodes); } return dir.getHdfsFileInfo(src); }
/** * Get the extended file info for a specific file. * * @param src * The string representation of the path to the file * @return object containing information regarding the file or null if file * not found * @throws IOException * if permission to access file is denied by the system */ FileStatusExtended getFileInfoExtended(String src, String leaseHolder) throws IOException { src = dir.normalizePath(src); INode[] inodes = dir.getExistingPathINodes(src); return dir.getFileInfoExtended(src, inodes[inodes.length - 1], leaseHolder); }
/** * Get the file info for a specific file. * * @param src The string representation of the path to the file * @return object containing information regarding the file * or null if file not found * @throws IOException if permission to access file is denied by the system */ FileStatus getFileInfo(String src) throws IOException { src = dir.normalizePath(src); INode[] inodes = dir.getExistingPathINodes(src); if (isPermissionEnabled) { checkTraverse(src, inodes); } return dir.getFileInfo(src, inodes[inodes.length-1]); }
ContentSummary getContentSummary(String src) throws IOException { INode[] inodes = dir.getExistingPathINodes(src); if (isPermissionEnabled) { checkPermission(src, inodes, false, null, null, null, FsAction.READ_EXECUTE); } readLock(); try { if (auditLog.isInfoEnabled()) { logAuditEvent(getCurrentUGI(), Server.getRemoteIp(), "getContentSummary", src, null, getLastINode(inodes)); } return dir.getContentSummary(src); } finally { readUnlock(); } }
/** * 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; }
INode [] trgINodes = getExistingPathINodes(target); INodeFile trgInode = (INodeFile) trgINodes[trgINodes.length-1]; INodeDirectory trgParent = (INodeDirectory)trgINodes[trgINodes.length-2];
private void setTimesInternal(String src, long mtime, long atime) throws IOException { writeLock(); try { if (isInSafeMode()) { throw new SafeModeException("Cannot set accesstimes for " + src, safeMode); } // // The caller needs to have write access to set access & modification times. if (isPermissionEnabled) { INode[] inodes = dir.getExistingPathINodes(src); checkPathAccess(src, inodes, FsAction.WRITE); } INodeFile inode = dir.getFileINode(src); if (inode != null) { dir.setTimes(src, inode, mtime, atime, true); if (auditLog.isInfoEnabled()) { logAuditEvent(getCurrentUGI(), Server.getRemoteIp(), "setTimes", src, null, inode); } } else { throw new FileNotFoundException("File " + src + " does not exist."); } } finally { writeUnlock(); } }
INode[] inodes = dir.getExistingPathINodes(src); checkPathAccess(src, inodes, FsAction.WRITE);
INode[] inodes = dir.getExistingPathINodes(src); checkPathAccess(src, inodes, FsAction.WRITE);
/** * Set permissions for an existing file. * * @throws IOException */ public void setPermission(String src, FsPermission permission ) throws IOException { INode[] inodes = null; writeLock(); try { if (isInSafeMode()) { throw new SafeModeException("Cannot set permission for " + src, safeMode); } inodes = dir.getExistingPathINodes(src); checkOwner(src, inodes); dir.setPermission(src, permission); } finally { writeUnlock(); } getEditLog().logSync(false); if (auditLog.isInfoEnabled()) { logAuditEvent(getCurrentUGI(), Server.getRemoteIp(), "setPermission", src, null, getLastINode(inodes)); } }
throw new SafeModeException("Cannot set permission for " + src, safeMode); inodes = dir.getExistingPathINodes(src); FSPermissionChecker pc = checkOwner(src, inodes); if (!pc.isSuper) {
INode[] pathINodes = dir.getExistingPathINodes(src); int inodesLen = pathINodes.length; checkLease(src, clientName, pathINodes[inodesLen-1]);
INode[] inodes = dir.getExistingPathINodes(src); inode = inodes[inodes.length - 1];