Java Code Examples for org.apache.flink.core.fs.Path#isAbsolute()

The following examples show how to use org.apache.flink.core.fs.Path#isAbsolute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MesosArtifactServer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: MesosArtifactServer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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());
	}
}
 
Example 3
Source File: CollectionExecutor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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");
	}
}
 
Example 4
Source File: MesosArtifactServer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: MesosArtifactServer.java    From flink with Apache License 2.0 5 votes vote down vote up
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());
	}
}
 
Example 6
Source File: CollectionExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
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");
	}
}
 
Example 7
Source File: MesosArtifactServer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: MesosArtifactServer.java    From flink with Apache License 2.0 5 votes vote down vote up
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());
	}
}
 
Example 9
Source File: CollectionExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
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");
	}
}
 
Example 10
Source File: FileUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Absolutize the given path if it is relative.
 *
 * @param pathToAbsolutize path which is being absolutized if it is a relative path
 * @return the absolutized path
 */
public static Path absolutizePath(Path pathToAbsolutize) throws IOException {
	if (!pathToAbsolutize.isAbsolute()) {
		FileSystem fs = pathToAbsolutize.getFileSystem();
		return new Path(fs.getWorkingDirectory(), pathToAbsolutize);
	} else {
		return pathToAbsolutize;
	}
}