/** * For example for the uri: alluxio://host:1000/foo/bar/baz, baz is the name. * * @return the last path component of the entity referenced by this uri, mutable */ public String getName() { return mInfo.getName(); }
@Test public void ignoreInvalidFiles() throws Exception { FileUtils.createDir(Paths.get(mUnderFS, "test").toString()); FileUtils.createFile(Paths.get(mUnderFS, "test", "a?b=C").toString()); FileUtils.createFile(Paths.get(mUnderFS, "test", "valid").toString()); List<FileInfo> listing = mFileSystemMaster.listStatus(new AlluxioURI("/test"), ListStatusContext.defaults(ListStatusPOptions.newBuilder() .setLoadMetadataType(LoadMetadataPType.ALWAYS).setRecursive(true))); assertEquals(1, listing.size()); assertEquals("valid", listing.get(0).getName()); }
private void verifyRename(TestUser user, String srcPath, String dstPath) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { String fileOwner = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(srcPath))) .getOwner(); mFileSystemMaster.rename(new AlluxioURI(srcPath), new AlluxioURI(dstPath), RenameContext.defaults()); assertEquals(-1, mFileSystemMaster.getFileId(new AlluxioURI(srcPath))); FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(dstPath))); String[] pathComponents = dstPath.split("/"); assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName()); assertEquals(fileOwner, fileInfo.getOwner()); } }
private void verifyCreateFile(TestUser user, String path, boolean recursive) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { CreateFileContext context = CreateFileContext .defaults( CreateFilePOptions.newBuilder().setRecursive(recursive)) .setOwner(SecurityUtils.getOwnerFromGrpcClient(ServerConfiguration.global())) .setGroup(SecurityUtils.getGroupFromGrpcClient(ServerConfiguration.global())) .setPersisted(true); long fileId = mFileSystemMaster.createFile(new AlluxioURI(path), context); FileInfo fileInfo = mFileSystemMaster.getFileInfo(fileId); String[] pathComponents = path.split("/"); assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName()); assertEquals(user.getUser(), fileInfo.getOwner()); } }
/** * Tests the {@link FileSystemMaster#delete(AlluxioURI, DeleteContext)} method with a * non-empty directory. */ @Test public void deleteNonemptyDirectory() throws Exception { createFileWithSingleBlock(NESTED_FILE_URI); String dirName = mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).getName(); try { mFileSystemMaster.delete(NESTED_URI, DeleteContext.defaults()); fail("Deleting a non-empty directory without setting recursive should fail"); } catch (DirectoryNotEmptyException e) { String expectedMessage = ExceptionMessage.DELETE_NONEMPTY_DIRECTORY_NONRECURSIVE.getMessage(dirName); assertEquals(expectedMessage, e.getMessage()); } // Now delete with recursive set to true. mFileSystemMaster.delete(NESTED_URI, DeleteContext.defaults(DeletePOptions.newBuilder().setRecursive(true))); }
private void verifyCreateDirectory(TestUser user, String path, boolean recursive) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { CreateDirectoryContext context = CreateDirectoryContext .defaults(CreateDirectoryPOptions.newBuilder().setRecursive(recursive)) .setOwner(SecurityUtils.getOwnerFromGrpcClient(ServerConfiguration.global())) .setGroup(SecurityUtils.getGroupFromGrpcClient(ServerConfiguration.global())); mFileSystemMaster.createDirectory(new AlluxioURI(path), context); FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(path))); String[] pathComponents = path.split("/"); assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName()); assertEquals(true, fileInfo.isFolder()); assertEquals(user.getUser(), fileInfo.getOwner()); } }
/** * Tests that an exception is thrown when trying to get information about a Directory after * it has been deleted after the TTL has been set to 0. */ @Test public void setSmallerTtlForDirectoryWithTtl() throws Exception { CreateDirectoryContext directoryContext = CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(Constants.HOUR_MS)) .setRecursive(true)); mFileSystemMaster.createDirectory(NESTED_URI, directoryContext); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); assertTrue( mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).getName() != null); mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setTtl(0))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is reset to 0, the file should have been deleted during last TTL check. mThrown.expect(FileDoesNotExistException.class); mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT); }
/** * Tests that the original TTL is removed after setting it to {@link Constants#NO_TTL} for * a directory. */ @Test public void setNoTtlForDirectoryWithTtl() throws Exception { mFileSystemMaster.createDirectory(new AlluxioURI("/nested"), CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true))); mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)) .setRecursive(true))); // After setting TTL to NO_TTL, the original TTL will be removed, and the file will not be // deleted during next TTL check. mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext .defaults(SetAttributePOptions.newBuilder().setTtl(Constants.NO_TTL))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); assertEquals(NESTED_URI.getName(), mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).getName()); }
/** * Tests that a directory has not been deleted after the TTL has been reset to a valid value. */ @Test public void setLargerTtlForDirectoryWithTtl() throws Exception { mFileSystemMaster.createDirectory(new AlluxioURI("/nested"), CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true))); mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext.defaults(CreateDirectoryPOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)) .setRecursive(true))); mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext .defaults(SetAttributePOptions.newBuilder().setTtl(Constants.HOUR_MS))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); // TTL is reset to 1 hour, the directory should not be deleted during last TTL check. assertEquals(NESTED_URI.getName(), mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).getName()); }
.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, baz is the name. * * @return the last path component of the entity referenced by this uri, mutable */ public String getName() { return mInfo.getName(); }
/** * For example for the uri: alluxio://host:1000/foo/bar/baz, baz is the name. * * @return the last path component of the entity referenced by this uri, mutable */ public String getName() { return mInfo.getName(); }
fileInfo.getLastModificationTimeMs()); Assert.assertEquals(uriStatus.getLength(), fileInfo.getLength()); Assert.assertEquals(uriStatus.getName(), fileInfo.getName()); Assert.assertEquals(uriStatus.getPath(), fileInfo.getPath()); Assert.assertEquals(uriStatus.getMode(), fileInfo.getMode());
@Override public void handleResponse(BackendlessCollection<FileInfo> fileInfoBackendlessCollection) { // create a list for your data List<String> infoList = new ArrayList<>(); Iterator<FileInfo> filesIterator = fileInfoBackendlessCollection.getCurrentPage().iterator(); while (filesIterator.hasNext()) { FileInfo file = filesIterator.next(); String URL = file.getURL(); String publicURL = file.getPublicUrl(); Date createdOn = new Date(file.getCreatedOn()); String name = file.getName(); // put everything into one string temporarily // String[] info = {URL, publicURL, name}; String info = URL + " " + publicURL + " " + name; infoList.add(info); } // loop through ALL your data before creating/assigning adapter ArrayAdapter<String> adapter = new ArrayAdapter<String>(getListView().getContext(), android.R.layout.simple_list_item_1, infoList); getListView().setAdapter(adapter); }