List of usage examples for org.apache.hadoop.fs FileStatus getGroup
public String getGroup()
From source file:TestFuseDFS.java
License:Apache License
/** * use shell to create a dir and then use filesys to see it exists. *///w w w . j av a2 s. c o m public void testChown() throws IOException, InterruptedException, Exception { try { // First create a new directory with mkdirs Path path = new Path("/foo"); Runtime r = Runtime.getRuntime(); String cmd = "mkdir -p " + mpoint + path.toString(); Process p = r.exec(cmd); assertTrue(p.waitFor() == 0); // check it is there assertTrue(fileSys.getFileStatus(path).isDir()); FileStatus foo = fileSys.getFileStatus(path); System.err.println("DEBUG:owner=" + foo.getOwner()); cmd = "chown nobody " + mpoint + path.toString(); p = r.exec(cmd); assertTrue(p.waitFor() == 0); // cmd = "chgrp nobody " + mpoint + path.toString(); // p = r.exec(cmd); // assertTrue(p.waitFor() == 0); foo = fileSys.getFileStatus(path); System.err.println("DEBUG:owner=" + foo.getOwner()); assertTrue(foo.getOwner().equals("nobody")); assertTrue(foo.getGroup().equals("nobody")); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with local UFS. It will test only * changing the owner of file using TFS and propagate the change to UFS. Since the arbitrary * owner does not exist in the local UFS, the operation would fail. *//*ww w .ja v a 2 s. co m*/ @Test public void changeNonexistentOwnerForLocal() throws Exception { // Skip non-local UFSs. Assume.assumeTrue(UnderFileSystemUtils.isLocal(sUfs)); Path fileA = new Path("/chownfileA-local"); final String nonexistentOwner = "nonexistent-user1"; final String nonexistentGroup = "nonexistent-group1"; create(sTFS, fileA); FileStatus fs = sTFS.getFileStatus(fileA); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA)).getOwner()); // Group can different because local FS user to group mapping can be different from that // in Alluxio. Assert.assertNotEquals(defaultOwner, nonexistentOwner); Assert.assertNotEquals(defaultGroup, nonexistentGroup); // Expect a IOException for not able to setOwner for UFS with invalid owner name. mThrown.expect(IOException.class); mThrown.expectMessage("Could not setOwner for UFS file"); sTFS.setOwner(fileA, nonexistentOwner, null); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with local UFS. It will test only * changing the group of file using TFS and propagate the change to UFS. Since the arbitrary * group does not exist in the local UFS, the operation would fail. *//*from w ww . ja v a 2s. c om*/ @Test public void changeNonexistentGroupForLocal() throws Exception { // Skip non-local UFSs. Assume.assumeTrue(UnderFileSystemUtils.isLocal(sUfs)); Path fileB = new Path("/chownfileB-local"); final String nonexistentOwner = "nonexistent-user1"; final String nonexistentGroup = "nonexistent-group1"; create(sTFS, fileB); FileStatus fs = sTFS.getFileStatus(fileB); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileB)).getOwner()); // Group can different because local FS user to group mapping can be different from that // in Alluxio. Assert.assertNotEquals(defaultOwner, nonexistentOwner); Assert.assertNotEquals(defaultGroup, nonexistentGroup); // Expect a IOException for not able to setOwner for UFS with invalid group name. mThrown.expect(IOException.class); mThrown.expectMessage("Could not setOwner for UFS file"); sTFS.setOwner(fileB, null, nonexistentGroup); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with local UFS. It will test * changing both owner and group of file using TFS and propagate the change to UFS. Since the * arbitrary owner and group do not exist in the local UFS, the operation would fail. *///from w w w . j av a 2 s . c om @Test public void changeNonexistentOwnerAndGroupForLocal() throws Exception { // Skip non-local UFSs. Assume.assumeTrue(UnderFileSystemUtils.isLocal(sUfs)); Path fileC = new Path("/chownfileC-local"); final String nonexistentOwner = "nonexistent-user1"; final String nonexistentGroup = "nonexistent-group1"; create(sTFS, fileC); FileStatus fs = sTFS.getFileStatus(fileC); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileC)).getOwner()); // Group can different because local FS user to group mapping can be different from that // in Alluxio. Assert.assertNotEquals(defaultOwner, nonexistentOwner); Assert.assertNotEquals(defaultGroup, nonexistentGroup); mThrown.expect(IOException.class); mThrown.expectMessage("Could not update owner"); sTFS.setOwner(fileC, nonexistentOwner, nonexistentGroup); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with HDFS UFS. It will test only * changing the owner of file using TFS and propagate the change to UFS. *//* w w w .j a va 2 s . co m*/ @Test public void changeNonexistentOwnerForHdfs() throws Exception { // Skip non-HDFS UFSs. Assume.assumeTrue(UnderFileSystemUtils.isHdfs(sUfs)); Path fileA = new Path("/chownfileA-hdfs"); final String testOwner = "test-user1"; final String testGroup = "test-group1"; create(sTFS, fileA); FileStatus fs = sTFS.getFileStatus(fileA); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA)).getOwner()); // Group can different because HDFS user to group mapping can be different from that in Alluxio. Assert.assertNotEquals(defaultOwner, testOwner); Assert.assertNotEquals(defaultGroup, testGroup); // Expect a IOException for not able to setOwner for UFS with invalid owner name. sTFS.setOwner(fileA, testOwner, null); fs = sTFS.getFileStatus(fileA); Assert.assertEquals(testOwner, fs.getOwner()); Assert.assertEquals(defaultGroup, fs.getGroup()); UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileA)); Assert.assertEquals(testOwner, ufsStatus.getOwner()); Assert.assertEquals(defaultGroup, ufsStatus.getGroup()); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with HDFS UFS. It will test only * changing the group of file using TFS and propagate the change to UFS. *///from w w w. j a va 2s . com @Test public void changeNonexistentGroupForHdfs() throws Exception { // Skip non-HDFS UFSs. Assume.assumeTrue(UnderFileSystemUtils.isHdfs(sUfs)); Path fileB = new Path("/chownfileB-hdfs"); final String testOwner = "test-user1"; final String testGroup = "test-group1"; create(sTFS, fileB); FileStatus fs = sTFS.getFileStatus(fileB); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileB)).getOwner()); // Group can different because HDFS user to group mapping can be different from that in Alluxio. Assert.assertNotEquals(defaultOwner, testOwner); Assert.assertNotEquals(defaultGroup, testGroup); sTFS.setOwner(fileB, null, testGroup); fs = sTFS.getFileStatus(fileB); Assert.assertEquals(defaultOwner, fs.getOwner()); Assert.assertEquals(testGroup, fs.getGroup()); UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileB)); Assert.assertEquals(defaultOwner, ufsStatus.getOwner()); Assert.assertEquals(testGroup, ufsStatus.getGroup()); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with HDFS UFS. It will test * changing both owner and group of file using TFS and propagate the change to UFS. *///www .java2s . c om @Test public void changeNonexistentOwnerAndGroupForHdfs() throws Exception { // Skip non-HDFS UFSs. Assume.assumeTrue(UnderFileSystemUtils.isHdfs(sUfs)); Path fileC = new Path("/chownfileC-hdfs"); final String testOwner = "test-user1"; final String testGroup = "test-group1"; create(sTFS, fileC); FileStatus fs = sTFS.getFileStatus(fileC); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileC)).getOwner()); // Group can different because HDFS user to group mapping can be different from that in Alluxio. Assert.assertNotEquals(defaultOwner, testOwner); Assert.assertNotEquals(defaultGroup, testGroup); sTFS.setOwner(fileC, testOwner, testGroup); fs = sTFS.getFileStatus(fileC); Assert.assertEquals(testOwner, fs.getOwner()); Assert.assertEquals(testGroup, fs.getGroup()); UfsStatus ufsStatus = sUfs.getFileStatus(PathUtils.concatPath(sUfsRoot, fileC)); Assert.assertEquals(testOwner, ufsStatus.getOwner()); Assert.assertEquals(testGroup, ufsStatus.getGroup()); }
From source file:alluxio.client.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)}. It will test both owner and group * are null./*from ww w . j a v a 2 s . co m*/ */ @Test public void checkNullOwnerAndGroup() throws Exception { Path fileD = new Path("/chownfileD"); create(sTFS, fileD); FileStatus fs = sTFS.getFileStatus(fileD); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); sTFS.setOwner(fileD, null, null); fs = sTFS.getFileStatus(fileD); Assert.assertEquals(defaultOwner, fs.getOwner()); Assert.assertEquals(defaultGroup, fs.getGroup()); }
From source file:alluxio.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with local UFS. It will test only * changing the owner of file using TFS and propagate the change to UFS. Since the arbitrary * owner does not exist in the local UFS, the operation would fail. *///from ww w . j av a2 s. c o m @Test public void changeNonexistentOwnerForLocal() throws Exception { if (!(sUfs instanceof LocalUnderFileSystem)) { // Skip non-local UFSs. return; } Path fileA = new Path("/chownfileA-local"); final String nonexistentOwner = "nonexistent-user1"; final String nonexistentGroup = "nonexistent-group1"; create(sTFS, fileA); FileStatus fs = sTFS.getFileStatus(fileA); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getOwner(PathUtils.concatPath(sUfsRoot, fileA))); Assert.assertEquals(defaultGroup, sUfs.getGroup(PathUtils.concatPath(sUfsRoot, fileA))); Assert.assertNotEquals(defaultOwner, nonexistentOwner); Assert.assertNotEquals(defaultGroup, nonexistentGroup); // Expect a IOException for not able to setOwner for UFS with invalid owner name. mThrown.expect(IOException.class); mThrown.expectMessage("Could not setOwner for UFS file"); sTFS.setOwner(fileA, nonexistentOwner, null); }
From source file:alluxio.hadoop.FileSystemAclIntegrationTest.java
License:Apache License
/** * Test for {@link FileSystem#setOwner(Path, String, String)} with local UFS. It will test only * changing the group of file using TFS and propagate the change to UFS. Since the arbitrary * group does not exist in the local UFS, the operation would fail. *//*w ww . jav a 2 s . com*/ @Test public void changeNonexistentGroupForLocal() throws Exception { if (!(sUfs instanceof LocalUnderFileSystem)) { // Skip non-local UFSs. return; } Path fileB = new Path("/chownfileB-local"); final String nonexistentOwner = "nonexistent-user1"; final String nonexistentGroup = "nonexistent-group1"; create(sTFS, fileB); FileStatus fs = sTFS.getFileStatus(fileB); String defaultOwner = fs.getOwner(); String defaultGroup = fs.getGroup(); Assert.assertEquals(defaultOwner, sUfs.getOwner(PathUtils.concatPath(sUfsRoot, fileB))); Assert.assertEquals(defaultGroup, sUfs.getGroup(PathUtils.concatPath(sUfsRoot, fileB))); Assert.assertNotEquals(defaultOwner, nonexistentOwner); Assert.assertNotEquals(defaultGroup, nonexistentGroup); // Expect a IOException for not able to setOwner for UFS with invalid group name. mThrown.expect(IOException.class); mThrown.expectMessage("Could not setOwner for UFS file"); sTFS.setOwner(fileB, null, nonexistentGroup); }