@Override public void setWorkingDirectory(Path path) { LOG.debug("setWorkingDirectory({})", path); if (path.isAbsolute()) { mWorkingDir = path; } else { mWorkingDir = new Path(mWorkingDir, path); } }
private Path makeAbsolute(Path f) { if (f.isAbsolute()) { return f; } else { return new Path(workingDir, f); } }
public static String keyFromPath(Path path) { checkArgument(path.isAbsolute(), "Path is not absolute: %s", path); String key = nullToEmpty(path.toUri().getPath()); if (key.startsWith(PATH_SEPARATOR)) { key = key.substring(PATH_SEPARATOR.length()); } if (key.endsWith(PATH_SEPARATOR)) { key = key.substring(0, key.length() - PATH_SEPARATOR.length()); } return key; }
/** * Resolve against given working directory. * * @param workDir * @param path * @return absolute path */ private Path makeAbsolute(Path workDir, Path path) { if (path.isAbsolute()) { return path; } return new Path(workDir, path); }
/** * Resolve against given working directory. * * * @param workDir * @param path * @return */ private Path makeAbsolute(Path workDir, Path path) { if (path.isAbsolute()) { return path; } return new Path(workDir, path); }
@Override public void setWorkingDirectory(final Path new_dir) { workingDir = new_dir.isAbsolute() ? new_dir : new Path(workingDir, new_dir); }
private Path makeAbsolute(final Path f) { return f.isAbsolute() ? f : new Path(workingDir, f); }
private String pathToObjectName(final Path path) { org.apache.hadoop.fs.Path hadoopPath = HadoopFileSystem.toHadoopPath(path); if (!hadoopPath.isAbsolute()) { hadoopPath = new org.apache.hadoop.fs.Path(fs.getWorkingDirectory(), hadoopPath); } return hadoopPath.toUri().getScheme() != null && hadoopPath.toUri().getPath().isEmpty() ? "" : hadoopPath.toUri().getPath().substring(1); }
/** * Is an absolute path (ie a slash relative path part) * AND a scheme is null AND authority is null. */ public static boolean isAbsoluteAndSchemeAuthorityNull(Path path) { return (path.isAbsolute() && path.toUri().getScheme() == null && path.toUri().getAuthority() == null); }
@Override public Path makeQualified(Path path) { // make sure that we just get the // path component Path fsPath = path; if (!path.isAbsolute()) { fsPath = new Path(archivePath, path); } URI tmpURI = fsPath.toUri(); //change this to Har uri return new Path(uri.getScheme(), harAuth, tmpURI.getPath()); }
public static Path makeAbsolute(FileSystem fileSystem, Path path) throws IOException { if (path.isAbsolute()) { return path; } else { return new Path(fileSystem.getWorkingDirectory(), path); } }
@Override public boolean isPathEncrypted(Path path) throws IOException { Path fullPath; if (path.isAbsolute()) { fullPath = path; } else { fullPath = path.getFileSystem(conf).makeQualified(path); } if(!"hdfs".equalsIgnoreCase(path.toUri().getScheme())) { return false; } return (getEncryptionZoneForPath(fullPath) != null); }
public static String addUserHomeDirectoryIfApplicable(String origPathStr, String user) throws IOException, URISyntaxException { if(origPathStr == null || origPathStr.isEmpty()) { return "/user/" + user; } Path p = new Path(origPathStr); if(p.isAbsolute()) { return origPathStr; } if(p.toUri().getPath().isEmpty()) { //origPathStr="hdfs://host:99" for example return new Path(p.toUri().getScheme(), p.toUri().getAuthority(), "/user/" + user).toString(); } //can't have relative path if there is scheme/authority return "/user/" + user + "/" + origPathStr; }
void checkNotRelative() { if (!isAbsolute() && toUri().getScheme() == null) { throw new HadoopIllegalArgumentException("Path is relative"); } }
/** * Converts Hadoop path to local path. * * @param path Hadoop path. * @return Local path. */ File convert(Path path) { checkPath(path); if (path.isAbsolute()) return new File(path.toUri().getPath()); return new File(getWorkingDirectory().toUri().getPath(), path.toUri().getPath()); }
/** * Convert Hadoop path into IGFS path. * * @param path Hadoop path. * @return IGFS path. */ @Nullable private IgfsPath convert(Path path) { if (path == null) return null; return path.isAbsolute() ? new IgfsPath(path.toUri().getPath()) : new IgfsPath(workingDir, path.toUri().getPath()); }
/** * @param path * @return full path including the chroot */ protected Path fullPath(final Path path) { super.checkPath(path); return path.isAbsolute() ? new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString) + path.toUri().getPath()) : new Path(chRootPathPartString + workingDir.toUri().getPath(), path); }
@VisibleForTesting static org.apache.hadoop.fs.Path generateStagingTempFilePath( org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path targetFile) throws IOException { checkArgument(targetFile.isAbsolute(), "targetFile must be absolute"); final org.apache.hadoop.fs.Path parent = targetFile.getParent(); final String name = targetFile.getName(); checkArgument(parent != null, "targetFile must not be the root directory"); while (true) { org.apache.hadoop.fs.Path candidate = new org.apache.hadoop.fs.Path( parent, "." + name + ".inprogress." + UUID.randomUUID().toString()); if (!fs.exists(candidate)) { return candidate; } } } }
/** Convert a path to a File. */ public File pathToFile(Path path) { checkPath(path); if (!path.isAbsolute()) { path = new Path(getWorkingDirectory(), path); } return new File(path.toUri().getPath()); }
/** * Convert Hadoop path into IGFS path. * * @param path Hadoop path. * @return IGFS path. */ @Nullable private IgfsPath convert(@Nullable Path path) { if (path == null) return null; return path.isAbsolute() ? new IgfsPath(path.toUri().getPath()) : new IgfsPath(convert(workingDir), path.toUri().getPath()); }