List of usage examples for org.apache.hadoop.fs FileSystem setWorkingDirectory
public abstract void setWorkingDirectory(Path new_dir);
From source file:org.trustedanalytics.samples.services.HdfsService.java
License:Apache License
/** * Setup FileSystem working directory for FileSystem object. * * @param fs FileSystem object will be modified so specific directory * with access rights will be set as working directory * * @return Path to working directory specifed by hdfs-shared instance * * @throws IOException io exception/*from ww w . j a v a2 s . co m*/ */ private Path setupWorkingDirectory(FileSystem fs) throws IOException { AppConfiguration appEnvConf = Configurations.newInstanceFromEnv(); ServiceInstanceConfiguration hdfsConf = appEnvConf.getServiceConfig(ServiceType.HDFS_TYPE); // Fetching home directory URI from application environment - ServiceType.HDFS_TYPE // the URI is specific for hdfs-shared instance Path path = new Path(hdfsConf.getProperty(Property.HDFS_URI).get()); // We will have read/write access to directory described in path variable fs.setWorkingDirectory(path); // returning a path just in case someone want to use it return path; }
From source file:org.trustedanalytics.utils.hdfs.HdfsConfigFactory.java
License:Apache License
private HdfsConfig createConfig(FileSystem fileSystem, String hdfsUri, String hdfsUser) throws IOException, LoginException { Path folder = new Path(hdfsUri); fileSystem.setWorkingDirectory(folder); return new HdfsConfig(fileSystem, hdfsUser, folder); }
From source file:org.trustedanalytics.utils.hdfs.TestHdfsConfigFactory.java
License:Apache License
private HdfsConfig createConfig(FileSystem fileSystem, String hdfsUri, String hdfsUser, Configuration config) throws IOException, LoginException { Path folder = new Path(hdfsUri); fileSystem.setWorkingDirectory(folder); return new HdfsConfig(fileSystem, hdfsUser, folder); }