/** * @param src the source file. * @param dest the destination file. * @param conf the configuration * @return true if the file names match else returns false. * @throws IOException when any file system related call fails */ private boolean checkPreExisting(FileSystem sourceFS, Path src, Path dest, Configuration conf) throws IOException { FileSystem destFS = dest.getFileSystem(conf); FileStatus destStatus = FileUtils.getFileStatusOrNull(destFS, dest); if (destStatus != null) { return (sourceFS.getFileStatus(src).getLen() == destStatus.getLen()); } return false; }
/** * @param src the source file. * @param dest the destination file. * @param conf the configuration * @return true if the file names match else returns false. * @throws IOException when any file system related call fails */ private boolean checkPreExisting(FileSystem sourceFS, Path src, Path dest, Configuration conf) throws IOException { FileSystem destFS = dest.getFileSystem(conf); FileStatus destStatus = FileUtils.getFileStatusOrNull(destFS, dest); if (destStatus != null) { return (sourceFS.getFileStatus(src).getLen() == destStatus.getLen()); } return false; }
/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
private HiveResourceACLs getResourceACLs(Path path) throws IOException { if (path == null) { throw new IllegalArgumentException("path is null"); } final FileSystem fs = path.getFileSystem(conf); FileStatus pathStatus = FileUtils.getFileStatusOrNull(fs, path); if (pathStatus != null) { return getResourceACLs(fs, pathStatus); } else if (path.getParent() != null) { // find the ancestor which exists to check its permissions Path par = path.getParent(); FileStatus parStatus = null; while (par != null) { parStatus = FileUtils.getFileStatusOrNull(fs, par); if (parStatus != null) { break; } par = par.getParent(); } return getResourceACLs(fs, parStatus); } return null; }
/** * Checks the permissions for the given path and current user on Hadoop FS. * If the given path does not exists, it checks for its parent folder. */ protected void checkPermissions(final Configuration conf, final Path path, final EnumSet<FsAction> actions) throws IOException, LoginException, HiveException { if (path == null) { throw new IllegalArgumentException("path is null"); } final FileSystem fs = path.getFileSystem(conf); FileStatus pathStatus = FileUtils.getFileStatusOrNull(fs, path); if (pathStatus != null) { checkPermissions(fs, pathStatus, actions, authenticator.getUserName()); } else if (path.getParent() != null) { // find the ancestor which exists to check its permissions Path par = path.getParent(); FileStatus parStatus = null; while (par != null) { parStatus = FileUtils.getFileStatusOrNull(fs, par); if (parStatus != null) { break; } par = par.getParent(); } checkPermissions(fs, parStatus, actions, authenticator.getUserName()); } }
/** * Checks the permissions for the given path and current user on Hadoop FS. * If the given path does not exists, it checks for its parent folder. */ protected void checkPermissions(final Configuration conf, final Path path, final EnumSet<FsAction> actions) throws IOException, LoginException, HiveException { if (path == null) { throw new IllegalArgumentException("path is null"); } final FileSystem fs = path.getFileSystem(conf); FileStatus pathStatus = FileUtils.getFileStatusOrNull(fs, path); if (pathStatus != null) { checkPermissions(fs, pathStatus, actions, authenticator.getUserName()); } else if (path.getParent() != null) { // find the ancestor which exists to check its permissions Path par = path.getParent(); FileStatus parStatus = null; while (par != null) { parStatus = FileUtils.getFileStatusOrNull(fs, par); if (parStatus != null) { break; } par = par.getParent(); } checkPermissions(fs, parStatus, actions, authenticator.getUserName()); } }
commitPaths.add(outPaths[idx]); } else if (!fs.rename(outPaths[idx], finalPaths[idx])) { FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, finalPaths[idx]); if (fileStatus != null) { LOG.warn("Target path " + finalPaths[idx] + " with a size " + fileStatus.getLen() + " exists. Trying to delete it.");
addPrivilegesFromFS(userName, availPrivs, fs, fileMatches, true); } else { FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, filePath); boolean pickParent = (fileStatus == null); // did we find the file/dir itself? if (pickParent){
FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, finalPaths[idx]); if (fileStatus != null) { LOG.warn("Target path " + finalPaths[idx] + " with a size " + fileStatus.getLen() + " exists. Trying to delete it.");
addPrivilegesFromFS(userName, availPrivs, fs, fileMatches, true); } else { FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, filePath); boolean pickParent = (fileStatus == null); // did we find the file/dir itself? if (pickParent){
/** * @param src the source file. * @param dest the destination file. * @param conf the configuration * @return true if the file names match else returns false. * @throws IOException when any file system related call fails */ private boolean checkPreExisting(Path src, Path dest, Configuration conf) throws IOException { FileSystem destFS = dest.getFileSystem(conf); FileSystem sourceFS = src.getFileSystem(conf); FileStatus destStatus = FileUtils.getFileStatusOrNull(destFS, dest); if (destStatus != null) { return (sourceFS.getFileStatus(src).getLen() == destStatus.getLen()); } return false; }
/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
/** * Checks the permissions for the given path and current user on Hadoop FS. * If the given path does not exists, it checks for its parent folder. */ protected void checkPermissions(final Configuration conf, final Path path, final EnumSet<FsAction> actions) throws IOException, LoginException, HiveException { if (path == null) { throw new IllegalArgumentException("path is null"); } final FileSystem fs = path.getFileSystem(conf); FileStatus pathStatus = FileUtils.getFileStatusOrNull(fs, path); if (pathStatus != null) { checkPermissions(fs, pathStatus, actions, authenticator.getUserName()); } else if (path.getParent() != null) { // find the ancestor which exists to check its permissions Path par = path.getParent(); FileStatus parStatus = null; while (par != null) { parStatus = FileUtils.getFileStatusOrNull(fs, par); if (parStatus != null) { break; } par = par.getParent(); } checkPermissions(fs, parStatus, actions, authenticator.getUserName()); } }
FileStatus destStatus = !replace ? FileUtils.getFileStatusOrNull(fs, destf) : null; if (destStatus != null && !destStatus.isDir()) { throw new HiveException("checkPaths: destination " + destf