/** * @return true if the given path is a snapshot path and the corresponding * INode is still in the current fsdirectory. */ private boolean isSnapshotPathInCurrent(String path) throws IOException { // if the parent path contains "/.snapshot/", this is a snapshot path if (path.contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR_SEPARATOR)) { String[] pathComponents = INode.getPathNames(path); if (HdfsConstants.DOT_SNAPSHOT_DIR .equals(pathComponents[pathComponents.length - 2])) { // this is a path for a specific snapshot (e.g., /foo/.snapshot/s1) return false; } String nonSnapshotPath = convertSnapshotPath(pathComponents); return dfs.getFileInfo(nonSnapshotPath) != null; } else { return false; } }
String[] components = INode.getPathNames(path); String[] components = INode.getPathNames(path);
/** * Breaks file path into components. * @param path * @return array of byte arrays each of which represents * a single path component. */ static byte[][] getPathComponents(String path) { return getPathComponents(getPathNames(path)); }
/** * @return true if the given path is a snapshot path and the corresponding * INode is still in the current fsdirectory. */ private boolean isSnapshotPathInCurrent(String path) throws IOException { // if the parent path contains "/.snapshot/", this is a snapshot path if (path.contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR_SEPARATOR)) { String[] pathComponents = INode.getPathNames(path); if (HdfsConstants.DOT_SNAPSHOT_DIR .equals(pathComponents[pathComponents.length - 2])) { // this is a path for a specific snapshot (e.g., /foo/.snapshot/s1) return false; } String nonSnapshotPath = convertSnapshotPath(pathComponents); return dfs.getFileInfo(nonSnapshotPath) != null; } else { return false; } }
/** * @return true if the given path is a snapshot path and the corresponding * INode is still in the current fsdirectory. */ private boolean isSnapshotPathInCurrent(String path) throws IOException { // if the parent path contains "/.snapshot/", this is a snapshot path if (path.contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR_SEPARATOR)) { String[] pathComponents = INode.getPathNames(path); if (HdfsConstants.DOT_SNAPSHOT_DIR .equals(pathComponents[pathComponents.length - 2])) { // this is a path for a specific snapshot (e.g., /foo/.snapshot/s1) return false; } String nonSnapshotPath = convertSnapshotPath(pathComponents); return dfs.getFileInfo(nonSnapshotPath) != null; } else { return false; } }
/** * Create a directory * If ancestor directories do not exist, automatically create them. * @param src string representation of the path to the directory * @param permissions the permission of the directory * @param inheritPermission if the permission of the directory should inherit * from its parent or not. The automatically created * ones always inherit its permission from its parent * @param now creation time * @return true if the operation succeeds false otherwise * @throws FileNotFoundException if an ancestor or itself is a file * @throws QuotaExceededException if directory creation violates * any quota limit */ boolean mkdirs(String src,PermissionStatus permissions, boolean inheritPermission, long now) throws FileNotFoundException, QuotaExceededException { src = normalizePath(src); String[] names = INode.getPathNames(src); byte[][] components = INode.getPathComponents(names); return mkdirs(src, names, components, null, names.length, permissions, inheritPermission, now); }
throws FileNotFoundException, QuotaExceededException { src = normalizePath(src); String[] names = INode.getPathNames(src); byte[][] components = INode.getPathComponents(names); INode[] inodes = new INode[components.length];
String[] components = INode.getPathNames(path); String[] components = INode.getPathNames(path);
private INode hardLinkToInternal(String src, String dst) throws IOException { String[] dstNames = INode.getPathNames(dst); if (!pathValidator.isValidName(dst, dstNames)) { numInvalidFilePathOperations++; String[] srcNames = INode.getPathNames(src); byte[][] srcComponents = INode.getPathComponents(srcNames); byte[][] dstComponents = INode.getPathComponents(dstNames);
try { if (srcInodes == null) { String[] srcNames = INode.getPathNames(src); srcLocalName = srcNames[srcNames.length-1]; byte[][] srcComponents = INode.getPathComponents(srcNames);
private INode renameToInternal(String src, String dst ) throws IOException { String[] dstNames = INode.getPathNames(dst); if (!pathValidator.isValidName(dst, dstNames)) { numInvalidFilePathOperations++; String[] srcNames = INode.getPathNames(src); byte[][] srcComponents = INode.getPathComponents(srcNames); byte[][] dstComponents = INode.getPathComponents(dstNames);
String[] components = INode.getPathNames(path); String[] components = INode.getPathNames(path);
String[] srcNames = INode.getPathNames(src); srcLocalName = srcNames[srcNames.length-1]; byte[][] srcComponents = INode.getPathComponents(srcNames);