/** * Check whether the filepath could be created * @throws SnapshotAccessControlException if path is in RO snapshot */ boolean isValidToCreate(String src, INodesInPath iip) throws SnapshotAccessControlException { String srcs = normalizePath(src); return srcs.startsWith("/") && !srcs.endsWith("/") && iip.getLastINode() == null; }
/** * Check whether the filepath could be created * @throws SnapshotAccessControlException if path is in RO snapshot */ boolean isValidToCreate(String src, INodesInPath iip) throws SnapshotAccessControlException { String srcs = normalizePath(src); return srcs.startsWith("/") && !srcs.endsWith("/") && iip.getLastINode() == null; }
/** * Check whether the filepath could be created * @throws SnapshotAccessControlException if path is in RO snapshot */ boolean isValidToCreate(String src, INodesInPath iip) throws SnapshotAccessControlException { String srcs = normalizePath(src); return srcs.startsWith("/") && !srcs.endsWith("/") && iip.getLastINode() == null; }
/** * Check whether the filepath could be created */ boolean isValidToCreate(String src) { String srcs = normalizePath(src); synchronized (rootDir) { if (srcs.startsWith("/") && !srcs.endsWith("/") && rootDir.getNode(srcs) == null) { return true; } else { return false; } } }
ContentSummary getContentSummary(String src) throws IOException { String srcs = normalizePath(src); synchronized (rootDir) { INode targetNode = rootDir.getNode(srcs); if (targetNode == null) { throw new FileNotFoundException("File does not exist: " + srcs); } else { return targetNode.computeContentSummary(); } } }
/** * Check whether the path specifies a directory */ boolean isDir(String src) { synchronized (rootDir) { INode node = rootDir.getNode(normalizePath(src)); return node != null && node.isDirectory(); } }
/** * 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); }
/** * Check whether the filepath could be created */ boolean isValidToCreate(String src) { String srcs = normalizePath(src); readLock(); try { if (srcs.startsWith("/") && !srcs.endsWith("/") && rootDir.getNode(srcs) == null) { return true; } else { return false; } } finally { readUnlock(); } }
/** 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 */ FileStatus getFileInfo(String src) { String srcs = normalizePath(src); synchronized (rootDir) { INode targetNode = rootDir.getNode(srcs); if (targetNode == null) { return null; } else { return createFileStatus(srcs, targetNode); } } }
boolean exists(String src) { src = normalizePath(src); synchronized(rootDir) { INode inode = rootDir.getNode(src); if (inode == null) { return false; } return inode.isDirectory()? true: ((INodeFile)inode).getBlocks() != null; } }
/** * 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 { String srcs = normalizePath(src); readLock(); try { INode targetNode = rootDir.getNode(srcs); if (targetNode == null) { throw new FileNotFoundException("File does not exist: " + srcs); } else { return targetNode.computeContentSummary(); } } finally { readUnlock(); } }
static List<XAttr> unprotectedRemoveXAttrs( FSDirectory fsd, final String src, final List<XAttr> toRemove) throws IOException { assert fsd.hasWriteLock(); INodesInPath iip = fsd.getINodesInPath4Write( FSDirectory.normalizePath(src), true); INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getLatestSnapshotId(); List<XAttr> existingXAttrs = XAttrStorage.readINodeXAttrs(inode); List<XAttr> removedXAttrs = Lists.newArrayListWithCapacity(toRemove.size()); List<XAttr> newXAttrs = filterINodeXAttrs(existingXAttrs, toRemove, removedXAttrs); if (existingXAttrs.size() != newXAttrs.size()) { XAttrStorage.updateINodeXAttrs(inode, newXAttrs, snapshotId); return removedXAttrs; } return null; }
/** * This is a method required in addition * to getFileInode * It returns the INode regardless of its type * getFileInode only returns the inode if it is * of a file type */ INode getInode(String src) { src = normalizePath(src); readLock(); try { INode inode = rootDir.getNode(src); return inode; } finally { readUnlock(); } }
/** * Check whether the path specifies a directory */ boolean isDir(String src) { readLock(); try { INode node = rootDir.getNode(normalizePath(src)); return isDir(node); } finally { readUnlock(); } }
boolean exists(String src) { src = normalizePath(src); readLock(); try { INode inode = rootDir.getNode(src); return exists(inode); } finally { readUnlock(); } }
/** * Check whether the path specifies a directory */ boolean isDir(String src) throws UnresolvedLinkException { src = normalizePath(src); readLock(); try { INode node = getINode(src, false); return node != null && node.isDirectory(); } finally { readUnlock(); } }
/** 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 */ FileStatus getFileInfo(String src, INode targetNode) { String srcs = normalizePath(src); readLock(); try { if (targetNode == null) { return null; } else { return createFileStatus(srcs, targetNode); } } finally { readUnlock(); } }
/** * Check whether the path specifies a directory */ boolean isDir(String src) throws UnresolvedLinkException { src = normalizePath(src); readLock(); try { INode node = getINode(src, false); return node != null && node.isDirectory(); } finally { readUnlock(); } }
static List<XAttr> unprotectedRemoveXAttrs( FSDirectory fsd, final String src, final List<XAttr> toRemove) throws IOException { assert fsd.hasWriteLock(); INodesInPath iip = fsd.getINodesInPath4Write( FSDirectory.normalizePath(src), true); INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getLatestSnapshotId(); List<XAttr> existingXAttrs = XAttrStorage.readINodeXAttrs(inode); List<XAttr> removedXAttrs = Lists.newArrayListWithCapacity(toRemove.size()); List<XAttr> newXAttrs = filterINodeXAttrs(existingXAttrs, toRemove, removedXAttrs); if (existingXAttrs.size() != newXAttrs.size()) { XAttrStorage.updateINodeXAttrs(inode, newXAttrs, snapshotId); return removedXAttrs; } return null; }