use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSEditLogOp method readAclEntriesFromXml.
private static List<AclEntry> readAclEntriesFromXml(Stanza st) {
List<AclEntry> aclEntries = Lists.newArrayList();
if (!st.hasChildren("ENTRY"))
return null;
List<Stanza> stanzas = st.getChildren("ENTRY");
for (Stanza s : stanzas) {
AclEntry e = new AclEntry.Builder().setScope(AclEntryScope.valueOf(s.getValue("SCOPE"))).setType(AclEntryType.valueOf(s.getValue("TYPE"))).setName(s.getValueOrNull("NAME")).setPermission(fsActionFromXml(s)).build();
aclEntries.add(e);
}
return aclEntries;
}
use of org.apache.hadoop.fs.permission.AclEntry in project SSM by Intel-bigdata.
the class EventBatchSerializer method convertAclEntry.
public static List<AclEntry> convertAclEntry(List<AclEntryProto> aclSpec) {
ArrayList<AclEntry> r = Lists.newArrayListWithCapacity(aclSpec.size());
for (AclEntryProto e : aclSpec) {
AclEntry.Builder builder = new AclEntry.Builder();
builder.setType(convert(e.getType()));
builder.setScope(convert(e.getScope()));
builder.setPermission(convert(e.getPermissions()));
if (e.hasName()) {
builder.setName(e.getName());
}
r.add(builder.build());
}
return r;
}
use of org.apache.hadoop.fs.permission.AclEntry in project hive by apache.
the class TestHdfsUtils method testSetFullFileStatusFailInheritAclsRecursive.
/**
* Tests that {@link HdfsUtils#setFullFileStatus(Configuration, HdfsUtils.HadoopFileStatus, FileSystem, Path, boolean)}
* does not thrown an exception when setting ACLs and with recursion.
*/
@Test
public void testSetFullFileStatusFailInheritAclsRecursive() throws Exception {
Configuration conf = new Configuration();
conf.set("dfs.namenode.acls.enabled", "true");
Path fakeTarget = new Path("fakePath");
HdfsUtils.HadoopFileStatus mockHadoopFileStatus = mock(HdfsUtils.HadoopFileStatus.class);
FileStatus mockSourceStatus = mock(FileStatus.class);
FsShell mockFsShell = mock(FsShell.class);
AclStatus mockAclStatus = mock(AclStatus.class);
when(mockSourceStatus.getPermission()).thenReturn(new FsPermission((short) 777));
when(mockAclStatus.toString()).thenReturn("");
when(mockHadoopFileStatus.getFileStatus()).thenReturn(mockSourceStatus);
when(mockHadoopFileStatus.getAclEntries()).thenReturn(new ArrayList<AclEntry>());
when(mockHadoopFileStatus.getAclStatus()).thenReturn(mockAclStatus);
doThrow(RuntimeException.class).when(mockFsShell).run(any(String[].class));
HdfsUtils.setFullFileStatus(conf, mockHadoopFileStatus, "", mock(FileSystem.class), fakeTarget, true, mockFsShell);
verify(mockFsShell).run(new String[] { "-setfacl", "-R", "--set", any(String.class), fakeTarget.toString() });
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class TestPBHelper method testAclStatusProto.
@Test
public void testAclStatusProto() {
AclEntry e = new AclEntry.Builder().setName("test").setPermission(FsAction.READ_EXECUTE).setScope(AclEntryScope.DEFAULT).setType(AclEntryType.OTHER).build();
AclStatus s = new AclStatus.Builder().owner("foo").group("bar").addEntry(e).build();
Assert.assertEquals(s, PBHelperClient.convert(PBHelperClient.convert(s)));
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class TestPBHelper method testAclEntryProto.
@Test
public void testAclEntryProto() {
// All fields populated.
AclEntry e1 = new AclEntry.Builder().setName("test").setPermission(FsAction.READ_EXECUTE).setScope(AclEntryScope.DEFAULT).setType(AclEntryType.OTHER).build();
// No name.
AclEntry e2 = new AclEntry.Builder().setScope(AclEntryScope.ACCESS).setType(AclEntryType.USER).setPermission(FsAction.ALL).build();
// No permission, which will default to the 0'th enum element.
AclEntry e3 = new AclEntry.Builder().setScope(AclEntryScope.ACCESS).setType(AclEntryType.USER).setName("test").build();
AclEntry[] expected = new AclEntry[] { e1, e2, new AclEntry.Builder().setScope(e3.getScope()).setType(e3.getType()).setName(e3.getName()).setPermission(FsAction.NONE).build() };
AclEntry[] actual = Lists.newArrayList(PBHelperClient.convertAclEntry(PBHelperClient.convertAclEntryProto(Lists.newArrayList(e1, e2, e3)))).toArray(new AclEntry[0]);
Assert.assertArrayEquals(expected, actual);
}
Aggregations