/** * For example, for the uri: alluxio://host:1000/foo/bar/baz, the path is /foo/bar/baz. * * @return the entire path component of the entity referenced by this uri, mutable */ public String getPath() { return mInfo.getPath(); }
/** * Prepares the destination file path of the given file id. Also creates the parent folder if it * does not exist. * * @param fileInfo the file info * @param ufs the {@link UnderFileSystem} instance * @return the path for persistence */ private String prepareUfsFilePath(FileInfo fileInfo, UnderFileSystem ufs) throws AlluxioException, IOException { AlluxioURI alluxioPath = new AlluxioURI(fileInfo.getPath()); FileSystem fs = mFileSystemFactory.get(); URIStatus status = fs.getStatus(alluxioPath); String ufsPath = status.getUfsPath(); UnderFileSystemUtils.prepareFilePath(alluxioPath, ufsPath, fs, ufs); return ufsPath; }
filenames.add(info.getPath());
private void verifyGetFileInfoOrList(TestUser user, String path, boolean isFile) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { if (isFile) { assertEquals(path, mFileSystemMaster .getFileInfo(new AlluxioURI(path), GetStatusContext.defaults()).getPath()); assertEquals(1, mFileSystemMaster .listStatus(new AlluxioURI(path), ListStatusContext.defaults()) .size()); } else { List<FileInfo> fileInfoList = mFileSystemMaster.listStatus(new AlluxioURI(path), ListStatusContext.defaults()); if (fileInfoList.size() > 0) { assertTrue(PathUtils.getParent(fileInfoList.get(0).getPath()).equals(path)); } } } }
@Test public void listStatusWithLoadMetadataOnce() throws Exception { AlluxioURI ufsMount = new AlluxioURI(mTestFolder.newFolder().getAbsolutePath()); mFileSystemMaster.createDirectory(new AlluxioURI("/mnt/"), CreateDirectoryContext.defaults()); // Create ufs file. Files.createDirectory(Paths.get(ufsMount.join("dir1").getPath())); Files.createFile(Paths.get(ufsMount.join("dir1").join("file1").getPath())); Files.createFile(Paths.get(ufsMount.join("dir1").join("file2").getPath())); mFileSystemMaster.mount(new AlluxioURI("/mnt/local"), ufsMount, MountContext.defaults()); // 3 directories exist. assertEquals(3, countPaths()); // getFileId should load metadata automatically. AlluxioURI uri = new AlluxioURI("/mnt/local/dir1"); List<FileInfo> fileInfoList = mFileSystemMaster.listStatus(uri, ListStatusContext.defaults()); Set<String> paths = new HashSet<>(); for (FileInfo fileInfo : fileInfoList) { paths.add(fileInfo.getPath()); } assertEquals(2, paths.size()); assertTrue(paths.contains("/mnt/local/dir1/file1")); assertTrue(paths.contains("/mnt/local/dir1/file2")); // listStatus should have loaded another 3 files (dir1, dir1/file1, dir1/file2), so now 6 // paths exist. assertEquals(6, countPaths()); }
Set<String> paths = new HashSet<>(); for (FileInfo fileInfo : fileInfoList) { paths.add(fileInfo.getPath());
assertEquals(ROOT_URI.getPath(), info.getPath()); assertEquals(ROOT_URI.getPath(), mFileSystemMaster.getFileInfo(ROOT_URI, GET_STATUS_CONTEXT).getPath()); assertEquals(NESTED_URI.getPath(), info.getPath()); assertEquals(NESTED_URI.getPath(), mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).getPath()); assertEquals(NESTED_FILE_URI.getPath(), info.getPath()); assertEquals(NESTED_FILE_URI.getPath(), mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).getPath());
@Test public void getFileInfoWithLoadMetadata() throws Exception { AlluxioURI ufsMount = new AlluxioURI(mTestFolder.newFolder().getAbsolutePath()); mFileSystemMaster.createDirectory(new AlluxioURI("/mnt/"), CreateDirectoryContext.defaults()); // Create ufs file. Files.createFile(Paths.get(ufsMount.join("file").getPath())); mFileSystemMaster.mount(new AlluxioURI("/mnt/local"), ufsMount, MountContext.defaults()); // 3 directories exist. assertEquals(3, countPaths()); // getFileInfo should load metadata automatically. AlluxioURI uri = new AlluxioURI("/mnt/local/file"); assertEquals(uri.getPath(), mFileSystemMaster.getFileInfo(uri, GET_STATUS_CONTEXT).getPath()); // getFileInfo should have loaded another file, so now 4 paths exist. assertEquals(4, countPaths()); }
paths.add(f.getPath());
.setFileId(fileInfo.getFileId()).setName(fileInfo.getName()).setPath(fileInfo.getPath()) .setUfsPath(fileInfo.getUfsPath()).setLength(fileInfo.getLength()) .setBlockSizeBytes(fileInfo.getBlockSizeBytes())
/** * Tests the {@link MutableInodeDirectory#generateClientFileInfo(String)} method. */ @Test public void generateClientFileInfo() { MutableInodeDirectory inodeDirectory = createInodeDirectory(); String path = "/test/path"; FileInfo info = inodeDirectory.generateClientFileInfo(path); Assert.assertEquals(inodeDirectory.getId(), info.getFileId()); Assert.assertEquals(inodeDirectory.getName(), info.getName()); Assert.assertEquals(path, info.getPath()); Assert.assertEquals("", info.getUfsPath()); Assert.assertEquals(0, info.getLength()); Assert.assertEquals(0, info.getBlockSizeBytes()); Assert.assertEquals(inodeDirectory.getCreationTimeMs(), info.getCreationTimeMs()); Assert.assertTrue(info.isCompleted()); Assert.assertTrue(info.isFolder()); Assert.assertEquals(inodeDirectory.isPinned(), info.isPinned()); Assert.assertFalse(info.isCacheable()); Assert.assertNotNull(info.getBlockIds()); Assert.assertEquals(inodeDirectory.getLastModificationTimeMs(), info.getLastModificationTimeMs()); } }
/** * For example, for the uri: alluxio://host:1000/foo/bar/baz, the path is /foo/bar/baz. * * @return the entire path component of the entity referenced by this uri, mutable */ public String getPath() { return mInfo.getPath(); }
/** * For example, for the uri: alluxio://host:1000/foo/bar/baz, the path is /foo/bar/baz. * * @return the entire path component of the entity referenced by this uri, mutable */ public String getPath() { return mInfo.getPath(); }
Assert.assertEquals(uriStatus.getLength(), fileInfo.getLength()); Assert.assertEquals(uriStatus.getName(), fileInfo.getName()); Assert.assertEquals(uriStatus.getPath(), fileInfo.getPath()); Assert.assertEquals(uriStatus.getMode(), fileInfo.getMode()); Assert.assertEquals(uriStatus.getPersistenceState(),
throw new FileDoesNotExistException(currentPath.toString()); downloadFile(new AlluxioURI(fileInfo.getPath()), request, response); } catch (FileDoesNotExistException e) { request.setAttribute("invalidPathError", "Error: Invalid Path " + e.getMessage());