/** * Adds a path to the artifact server. * @param path the qualified FS path to serve (local, hdfs, etc). * @param remoteFile the remote path with which to locate the file. * @return the fully-qualified remote path to the file. * @throws MalformedURLException if the remote path is invalid. */ public synchronized URL addPath(Path path, Path remoteFile) throws IOException, MalformedURLException { if (paths.containsKey(remoteFile)) { throw new IllegalArgumentException("duplicate path registered"); } if (remoteFile.isAbsolute()) { throw new IllegalArgumentException("not expecting an absolute path"); } URL fileURL = new URL(baseURL, remoteFile.toString()); router.addAny(fileURL.getPath(), new VirtualFileServerHandler(path)); paths.put(remoteFile, fileURL); return fileURL; }
/** * Converts the given Path to a File for this file system. * * <p>If the path is not absolute, it is interpreted relative to this FileSystem's working directory. */ public File pathToFile(Path path) { if (!path.isAbsolute()) { path = new Path(getWorkingDirectory(), path); } return new File(path.toUri().getPath()); }
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }
/** * Returns a qualified path object. * * @param fs * the FileSystem that should be used to obtain the current working directory * @return the qualified path object */ public Path makeQualified(FileSystem fs) { Path path = this; if (!isAbsolute()) { path = new Path(fs.getWorkingDirectory(), this); } final URI pathUri = path.toUri(); final URI fsUri = fs.getUri(); String scheme = pathUri.getScheme(); String authority = pathUri.getAuthority(); if (scheme != null && (authority != null || fsUri.getAuthority() == null)) { return path; } if (scheme == null) { scheme = fsUri.getScheme(); } if (authority == null) { authority = fsUri.getAuthority(); if (authority == null) { authority = ""; } } return new Path(scheme + ":" + "//" + authority + pathUri.getPath()); }
public VirtualFileServerHandler(Path path) throws IOException { this.path = path; if (!path.isAbsolute()) { throw new IllegalArgumentException("path must be absolute: " + path.toString()); } this.fs = path.getFileSystem(); if (!fs.exists(path) || fs.getFileStatus(path).isDir()) { throw new IllegalArgumentException("no such file: " + path.toString()); } }
assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertFalse(p.isAbsolute()); assertFalse(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute()); assertFalse(p.isAbsolute()); assertTrue(p.isAbsolute()); assertFalse(p.isAbsolute()); assertTrue(p.isAbsolute()); assertTrue(p.isAbsolute());
public Artifact(Path source, Path dest, boolean executable, boolean cachable, boolean extract) { checkArgument(source.isAbsolute(), "source must be absolute"); checkArgument(!dest.isAbsolute(), "destination must be relative"); this.source = source; this.dest = dest; this.executable = executable; this.cachable = cachable; this.extract = extract; }
public Artifact(Path source, Path dest, boolean executable, boolean cachable, boolean extract) { checkArgument(source.isAbsolute(), "source must be absolute"); checkArgument(!dest.isAbsolute(), "destination must be relative"); this.source = source; this.dest = dest; this.executable = executable; this.cachable = cachable; this.extract = extract; }
public Artifact(Path source, Path dest, boolean executable, boolean cachable, boolean extract) { checkArgument(source.isAbsolute(), "source must be absolute"); checkArgument(!dest.isAbsolute(), "destination must be relative"); this.source = source; this.dest = dest; this.executable = executable; this.cachable = cachable; this.extract = extract; }
public Artifact(Path source, Path dest, boolean executable, boolean cachable, boolean extract) { checkArgument(source.isAbsolute(), "source must be absolute"); checkArgument(!dest.isAbsolute(), "destination must be relative"); this.source = source; this.dest = dest; this.executable = executable; this.cachable = cachable; this.extract = extract; }
/** * Converts the given Path to a File for this file system. * * <p>If the path is not absolute, it is interpreted relative to this FileSystem's working directory. */ public File pathToFile(Path path) { if (!path.isAbsolute()) { path = new Path(getWorkingDirectory(), path); } return new File(path.toUri().getPath()); }
private File pathToFile(Path path) { if (!path.isAbsolute()) { path = new Path(getWorkingDirectory(), path); } return new File(path.toUri().getPath()); }
/** * Returns a qualified path object. * * @param fs * the FileSystem that should be used to obtain the current working directory * @return the qualified path object */ public Path makeQualified(FileSystem fs) { Path path = this; if (!isAbsolute()) { path = new Path(fs.getWorkingDirectory(), this); } final URI pathUri = path.toUri(); final URI fsUri = fs.getUri(); String scheme = pathUri.getScheme(); String authority = pathUri.getAuthority(); if (scheme != null && (authority != null || fsUri.getAuthority() == null)) { return path; } if (scheme == null) { scheme = fsUri.getScheme(); } if (authority == null) { authority = fsUri.getAuthority(); if (authority == null) { authority = ""; } } return new Path(scheme + ":" + "//" + authority + pathUri.getPath()); }
/** * Returns a qualified path object. * * @param fs * the FileSystem that should be used to obtain the current working directory * @return the qualified path object */ public Path makeQualified(FileSystem fs) { Path path = this; if (!isAbsolute()) { path = new Path(fs.getWorkingDirectory(), this); } final URI pathUri = path.toUri(); final URI fsUri = fs.getUri(); String scheme = pathUri.getScheme(); String authority = pathUri.getAuthority(); if (scheme != null && (authority != null || fsUri.getAuthority() == null)) { return path; } if (scheme == null) { scheme = fsUri.getScheme(); } if (authority == null) { authority = fsUri.getAuthority(); if (authority == null) { authority = ""; } } return new Path(scheme + ":" + "//" + authority + pathUri.getPath()); }
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }