use of org.apache.twill.filesystem.ForwardingLocationFactory in project cdap by caskdata.
the class SparkPackageUtils method resolveURI.
/**
* Resolves a {@link URI} representation from the given {@link Location}. It resolves the URI in the same way
* as Spark does.
*/
private static URI resolveURI(Location location) throws IOException {
LocationFactory locationFactory = location.getLocationFactory();
while (locationFactory instanceof ForwardingLocationFactory) {
locationFactory = ((ForwardingLocationFactory) locationFactory).getDelegate();
}
if (!(locationFactory instanceof FileContextLocationFactory)) {
return location.toURI();
}
// Resolves the URI the way as Spark does
Configuration hConf = ((FileContextLocationFactory) locationFactory).getConfiguration();
org.apache.hadoop.fs.Path path = new org.apache.hadoop.fs.Path(location.toURI().getPath());
path = path.getFileSystem(hConf).makeQualified(path);
return ((FileContextLocationFactory) locationFactory).getFileContext().resolvePath(path).toUri();
}
Aggregations