@Override public String getOwner() { return realStatus.getOwner(); }
@Override public String getOwner() { return myFs.getOwner(); }
@Override public Object run() throws Exception { // need to use a new filesystem object here to have the correct ugi FileSystem proxyFs = p.getFileSystem(conf); FileStatus stat = proxyFs.getFileStatus(p); wrapper.add(stat.getOwner()); return null; } });
@Override public Object run() throws Exception { FileStatus stat = fs.getFileStatus(p); wrapper.add(stat.getOwner()); return null; } });
/** * Move the path to trash as the owner of the path. * @param path {@link org.apache.hadoop.fs.Path} to move. * @return true if the move succeeded. * @throws IOException */ public boolean moveToTrashAsOwner(Path path) throws IOException { String owner = this.fs.getFileStatus(path).getOwner(); return moveToTrashAsUser(path, owner); }
/** * Set the group associated with a given path. * * @param fs the {@link FileSystem} instance used to perform the file operation * @param path the given path * @param group the group associated with the path * @throws IOException */ public static void setGroup(FileSystem fs, Path path, String group) throws IOException { fs.setOwner(path, fs.getFileStatus(path).getOwner(), group); }
@Override public UfsFileStatus getFileStatus(String path) throws IOException { Path tPath = new Path(path); FileSystem hdfs = getFs(); FileStatus fs = hdfs.getFileStatus(tPath); String contentHash = UnderFileSystemUtils.approximateContentHash(fs.getLen(), fs.getModificationTime()); return new UfsFileStatus(path, contentHash, fs.getLen(), fs.getModificationTime(), fs.getOwner(), fs.getGroup(), fs.getPermission().toShort()); }
@Override public String getOwner() { if (!isPermissionLoaded()) { loadPermissionInfo(); } return super.getOwner(); }
@Override public UfsDirectoryStatus getDirectoryStatus(String path) throws IOException { Path tPath = new Path(path); FileSystem hdfs = getFs(); FileStatus fs = hdfs.getFileStatus(tPath); return new UfsDirectoryStatus(path, fs.getOwner(), fs.getGroup(), fs.getPermission().toShort(), fs.getModificationTime()); }
@Override public UfsStatus getStatus(String path) throws IOException { Path tPath = new Path(path); FileSystem hdfs = getFs(); FileStatus fs = hdfs.getFileStatus(tPath); if (!fs.isDir()) { // Return file status. String contentHash = UnderFileSystemUtils.approximateContentHash(fs.getLen(), fs.getModificationTime()); return new UfsFileStatus(path, contentHash, fs.getLen(), fs.getModificationTime(), fs.getOwner(), fs.getGroup(), fs.getPermission().toShort()); } // Return directory status. return new UfsDirectoryStatus(path, fs.getOwner(), fs.getGroup(), fs.getPermission().toShort(), fs.getModificationTime()); }
protected FileStatus swizzleFileStatus(FileStatus orig, boolean isParam) { FileStatus ret = new FileStatus(orig.getLen(), orig.isDir(), orig.getReplication(), orig.getBlockSize(), orig.getModificationTime(), orig.getAccessTime(), orig.getPermission(), orig.getOwner(), orig.getGroup(), isParam ? swizzleParamPath(orig.getPath()) : swizzleReturnPath(orig.getPath())); return ret; }
/** {@inheritDoc} */ @Override public Map<String, String> properties(String path) throws IOException { Path p = new Path(path); FileStatus status = get().getFileStatus(p); Map<String,String> m = new HashMap<>(3); m.put(IgfsUtils.PROP_USER_NAME, status.getOwner()); m.put(IgfsUtils.PROP_GROUP_NAME, status.getGroup()); m.put(IgfsUtils.PROP_PERMISSION, permission(status)); return m; }
/** @throws Exception If failed. */ @Test public void testSetOwner() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); FSDataOutputStream os = fs.create(file); os.close(); assertEquals(getClientFsUser(), fs.getFileStatus(file).getOwner()); fs.setOwner(file, "aUser", "aGroup"); assertEquals("aUser", fs.getFileStatus(file).getOwner()); assertEquals("aGroup", fs.getFileStatus(file).getGroup()); }
public void touch(MockFile file) { if (fileStatusMap.containsKey(file)) { FileStatus fileStatus = fileStatusMap.get(file); FileStatus fileStatusNew = new FileStatus(fileStatus.getLen(), fileStatus.isDirectory(), fileStatus.getReplication(), fileStatus.getBlockSize(), fileStatus.getModificationTime() + 1, fileStatus.getAccessTime(), fileStatus.getPermission(), fileStatus.getOwner(), fileStatus.getGroup(), fileStatus.getPath()); fileStatusMap.put(file, fileStatusNew); } }
public void touch(MockFile file) { if (fileStatusMap.containsKey(file)) { FileStatus fileStatus = fileStatusMap.get(file); FileStatus fileStatusNew = new FileStatus(fileStatus.getLen(), fileStatus.isDirectory(), fileStatus.getReplication(), fileStatus.getBlockSize(), fileStatus.getModificationTime() + 1, fileStatus.getAccessTime(), fileStatus.getPermission(), fileStatus.getOwner(), fileStatus.getGroup(), fileStatus.getPath()); fileStatusMap.put(file, fileStatusNew); } }
/** * @throws Exception If failed. */ @Test public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); FSDataOutputStream os = fs.create(file); fs.setOwner(file, "aUser", "aGroup"); os.close(); assertEquals("aUser", fs.getFileStatus(file).getOwner()); assertEquals("aGroup", fs.getFileStatus(file).getGroup()); }
/** @throws Exception If failed. */ @Test public void testSetOwnerCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); FSDataOutputStream os = fs.create(file); os.close(); Path tmpDir = new Path(fsHome, "/tmp"); fs.setOwner(file, "fUser", "fGroup"); fs.setOwner(tmpDir, "dUser", "dGroup"); assertEquals("dUser", fs.getFileStatus(tmpDir).getOwner()); assertEquals("dGroup", fs.getFileStatus(tmpDir).getGroup()); assertEquals("fUser", fs.getFileStatus(file).getOwner()); assertEquals("fGroup", fs.getFileStatus(file).getGroup()); }
/** @throws Exception If failed. */ @Test public void testSetOwner() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); FSDataOutputStream os = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault())); os.close(); assertEquals(getClientFsUser(), fs.getFileStatus(file).getOwner()); fs.setOwner(file, "aUser", "aGroup"); assertEquals("aUser", fs.getFileStatus(file).getOwner()); assertEquals("aGroup", fs.getFileStatus(file).getGroup()); }
/** @throws Exception If failed. */ @Test public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); FSDataOutputStream os = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault())); fs.setOwner(file, "aUser", "aGroup"); os.close(); assertEquals("aUser", fs.getFileStatus(file).getOwner()); assertEquals("aGroup", fs.getFileStatus(file).getGroup()); }
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()); } }