/** * Set the current working directory for the given file system. All relative * paths will be resolved relative to it. * * @param newDir */ @Override public void setWorkingDirectory(Path newDir) { fs.setWorkingDirectory(newDir); }
@Override public FileSystem run() throws Exception { FileSystem fs = FileSystem.get(fullUri, cfg); if (workDir != null) fs.setWorkingDirectory(workDir); return fs; } });
/** * Internal file system creation routine, invoked in correct class loader context. * * @param usrName User name. * @return File system. * @throws IOException If failed. * @throws InterruptedException if the current thread is interrupted. */ protected FileSystem create(String usrName) throws IOException, InterruptedException { FileSystem fs = FileSystem.get(fullUri, cfg, usrName); if (workDir != null) fs.setWorkingDirectory(workDir); return fs; }
public void setWorkingDirectory(Path new_dir) { this.underlyingFs.setWorkingDirectory(replaceScheme(new_dir, this.replacementScheme, this.underlyingScheme)); }
@Before public void openFileSystem() throws Exception { conf = new Configuration(); fs = FileSystem.getLocal(conf); Path workDir = new Path(System.getProperty("test.tmp.dir", "target" + File.separator + "test" + File.separator + "tmp")); fs.setWorkingDirectory(workDir); testFilePath = new Path("TestVectorizedORCReader.testDump.orc"); fs.delete(testFilePath, false); }
/** @throws Exception If failed. */ @Test public void testSetWorkingDirectoryIfPathDoesNotExist() throws Exception { // Should not throw any exceptions. fs.setWorkingDirectory(new Path("/someDir")); }
/** @throws Exception If failed. */ @Test public void testSetWorkingDirectory() throws Exception { Path dir = new Path("/tmp/nested/dir"); Path file = new Path("file"); fs.mkdirs(dir); fs.setWorkingDirectory(dir); FSDataOutputStream os = fs.create(file); os.close(); String filePath = fs.getFileStatus(new Path(dir, file)).getPath().toString(); assertTrue(filePath.contains("/tmp/nested/dir/file")); }
/** @throws Exception If failed. */ @Test public void testSetWorkingDirectoryIfPathIsNull() throws Exception { fs.setWorkingDirectory(null); Path file = new Path("file"); FSDataOutputStream os = fs.create(file); os.close(); String path = fs.getFileStatus(file).getPath().toString(); assertTrue(path.endsWith("/user/" + getClientFsUser() + "/file")); }
/** @throws Exception If failed. */ @Test public void testGetWorkingDirectory() throws Exception { Path dir = new Path("/tmp/some/dir"); fs.mkdirs(dir); fs.setWorkingDirectory(dir); String path = fs.getWorkingDirectory().toString(); assertTrue(path.endsWith("/tmp/some/dir")); }
@Override public void run() { try { int curThreadNum = threadNum.getAndIncrement(); if ("file".equals(uri.getScheme())) FileSystem.get(uri, cfg).setWorkingDirectory(new Path("file:///user/user" + curThreadNum)); changeUserPhase.countDown(); changeUserPhase.await(); newUserInitWorkDir[curThreadNum] = FileSystem.get(uri, cfg).getWorkingDirectory(); FileSystem.get(uri, cfg).setWorkingDirectory(new Path("folder" + curThreadNum)); changeDirPhase.countDown(); changeDirPhase.await(); newWorkDir[curThreadNum] = FileSystem.get(uri, cfg).getWorkingDirectory(); FileSystem.get(uri, cfg).setWorkingDirectory(new Path("/folder" + curThreadNum)); changeAbsDirPhase.countDown(); changeAbsDirPhase.await(); newAbsWorkDir[curThreadNum] = FileSystem.get(uri, cfg).getWorkingDirectory(); newInstanceWorkDir[curThreadNum] = FileSystem.newInstance(uri, cfg).getWorkingDirectory(); finishPhase.countDown(); } catch (InterruptedException | IOException e) { error("Failed to execute test thread.", e); fail(); } } }, THREAD_COUNT, "filesystems-test");
/** * Set the current working directory for the given file system. All relative * paths will be resolved relative to it. * * @param newDir */ @Override public void setWorkingDirectory(Path newDir) { fs.setWorkingDirectory(newDir); }
/** * Set the current working directory for the given file system. All relative * paths will be resolved relative to it. * * @param newDir */ @Override public void setWorkingDirectory(Path newDir) { fs.setWorkingDirectory(newDir); }
fs.setPermission(TEST_VISIBILITY_CHILD_DIR, new FsPermission((short)00777)); fs.setWorkingDirectory(TEST_VISIBILITY_CHILD_DIR); Job job = Job.getInstance(conf); Path relativePath = new Path(SECOND_CACHE_FILE);
public void updateCurrentWorkingDirectory() { final String currentDir = this.getCurrentDir(); if (StringUtils.isEmpty(currentDir)) { return; } try { FileSystem.get(new Configuration()).setWorkingDirectory(new Path(currentDir)); } catch (Exception e) { //ignore // e.printStackTrace(); } }
@Override public void setWorkingDirectory(Path new_dir) { Span span = Trace.start("setWorkingDirectory"); try { impl.setWorkingDirectory(new_dir); } finally { span.stop(); } }
@Override public Object run() throws Exception { try { // use job-specified working directory FileSystem.get(job).setWorkingDirectory(job.getWorkingDirectory()); taskFinal.run(job, umbilical); // run the task } finally { TaskLog.syncLogs(logLocation, taskid, isCleanup); } return null; } });
@Test public void testWDAbsolute() throws IOException { Path absoluteDir = new Path(fSys.getUri() + "/test/existingDir"); fSys.mkdirs(absoluteDir); fSys.setWorkingDirectory(absoluteDir); Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory()); }
@Test public void testWDAbsolute() throws IOException { Path absoluteDir = new Path(fSys.getUri() + "/test/existingDir"); fSys.mkdirs(absoluteDir); fSys.setWorkingDirectory(absoluteDir); Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory()); }
@Test @Override public void testWDAbsolute() throws IOException { Path absoluteDir = getTestRootPath(fSys, "test/existingDir"); fSys.mkdirs(absoluteDir); fSys.setWorkingDirectory(absoluteDir); Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory()); } }
@Test @Override public void testWDAbsolute() throws IOException { Path absoluteDir = getTestRootPath(fSys, "test/existingDir"); fSys.mkdirs(absoluteDir); fSys.setWorkingDirectory(absoluteDir); Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory()); } }