/** * @return the owner of the entity referenced by this uri, mutable */ public String getOwner() { return mInfo.getOwner(); }
OutputStream outputStream = ufs.create(dstPath, CreateOptions.defaults(ServerConfiguration.global()) .setOwner(fileInfo.getOwner()).setGroup(fileInfo.getGroup()) .setMode(new Mode((short) fileInfo.getMode()))); final WritableByteChannel outputChannel = Channels.newChannel(outputStream);
private void assertFileInfoEqualsFileStatus(FileInfo info, FileStatus status) { assertEquals(info.getOwner(), status.getOwner()); assertEquals(info.getGroup(), status.getGroup()); assertEquals(info.getMode(), status.getPermission().toShort()); assertEquals(info.getLastModificationTimeMs(), status.getModificationTime()); assertEquals(info.isFolder(), status.isDir()); } }
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()); } }
@Test public void setOwnerSuccess() throws Exception { verifySetAcl(TEST_USER_ADMIN, TEST_FILE_URI, TEST_USER_1.getUser(), null, (short) -1, false); verifySetAcl(TEST_USER_SUPERGROUP, TEST_DIR_URI, TEST_USER_2.getUser(), null, (short) -1, true); FileInfo fileInfo = mFileSystemMaster .getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(TEST_DIR_FILE_URI))); assertEquals(TEST_USER_2.getUser(), 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()); } }
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()); } }
.addAllBlockIds(fileInfo.getBlockIds()) .setLastModificationTimeMs(fileInfo.getLastModificationTimeMs()).setTtl(fileInfo.getTtl()) .setOwner(fileInfo.getOwner()).setGroup(fileInfo.getGroup()).setMode(fileInfo.getMode()) .setPersistenceState(fileInfo.getPersistenceState()).setMountPoint(fileInfo.isMountPoint()) .addAllFileBlockInfos(fileBlockInfos)
private void verifySetAcl(TestUser runUser, String path, String owner, String group, short mode, boolean recursive) throws Exception { try (Closeable r = new AuthenticatedUserRule(runUser.getUser(), ServerConfiguration.global()).toResource()) { SetAttributeContext context = SetAttributeContext.defaults(SetAttributePOptions.newBuilder() .setMode(new Mode(mode).toProto()).setRecursive(recursive)); if (owner != null) { context.getOptions().setOwner(owner); } if (group != null) { context.getOptions().setGroup(group); } mFileSystemMaster.setAttribute(new AlluxioURI(path), context); } try (Closeable r = new AuthenticatedUserRule(TEST_USER_ADMIN.getUser(), ServerConfiguration.global()).toResource()) { FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(path))); if (owner != null) { assertEquals(owner, fileInfo.getOwner()); } if (group != null) { assertEquals(group, fileInfo.getGroup()); } if (mode != -1) { assertEquals(mode, fileInfo.getMode()); } } }
/** * @return the owner of the entity referenced by this uri, mutable */ public String getOwner() { return mInfo.getOwner(); }
Assert.assertEquals(uriStatus.getTtlAction(), fileInfo.getTtlAction()); Assert.assertEquals(uriStatus.getUfsPath(), fileInfo.getUfsPath()); Assert.assertEquals(uriStatus.getOwner(), fileInfo.getOwner()); Assert.assertEquals(uriStatus.isCacheable(), fileInfo.isCacheable()); Assert.assertEquals(uriStatus.isCompleted(), fileInfo.isCompleted());