当前位置: 首页>>代码示例>>Java>>正文


Java AclEntry类代码示例

本文整理汇总了Java中org.apache.hadoop.fs.permission.AclEntry的典型用法代码示例。如果您正苦于以下问题:Java AclEntry类的具体用法?Java AclEntry怎么用?Java AclEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AclEntry类属于org.apache.hadoop.fs.permission包,在下文中一共展示了AclEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAcl

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
static HdfsFileStatus setAcl(
    FSDirectory fsd, final String srcArg, List<AclEntry> aclSpec)
    throws IOException {
  String src = srcArg;
  checkAclsConfigFlag(fsd);
  byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
  FSPermissionChecker pc = fsd.getPermissionChecker();
  src = fsd.resolvePath(pc, src, pathComponents);
  INodesInPath iip;
  fsd.writeLock();
  try {
    iip = fsd.getINodesInPath4Write(src);
    fsd.checkOwner(pc, iip);
    List<AclEntry> newAcl = unprotectedSetAcl(fsd, src, aclSpec, false);
    fsd.getEditLog().logSetAcl(src, newAcl);
  } finally {
    fsd.writeUnlock();
  }
  return fsd.getAuditFileInfo(iip);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:FSDirAclOp.java

示例2: testFilterDefaultAclEntries

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testFilterDefaultAclEntries() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_WRITE))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, GROUP, "sales", READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .add(aclEntry(DEFAULT, USER, ALL))
    .add(aclEntry(DEFAULT, USER, "bruce", READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, GROUP, "sales", READ_EXECUTE))
    .add(aclEntry(DEFAULT, MASK, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, READ_EXECUTE))
    .build();
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_WRITE))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, GROUP, "sales", READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  assertEquals(expected, filterDefaultAclEntries(existing));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestAclTransformation.java

示例3: getAclEntryList

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
private List<AclEntry> getAclEntryList(String path) throws IOException {
  long id = lookup(path);
  FsImageProto.INodeSection.INode inode = fromINodeId(id);
  switch (inode.getType()) {
    case FILE: {
      FsImageProto.INodeSection.INodeFile f = inode.getFile();
      return FSImageFormatPBINode.Loader.loadAclEntries(
          f.getAcl(), stringTable);
    }
    case DIRECTORY: {
      FsImageProto.INodeSection.INodeDirectory d = inode.getDirectory();
      return FSImageFormatPBINode.Loader.loadAclEntries(
          d.getAcl(), stringTable);
    }
    default: {
      return new ArrayList<AclEntry>();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSImageLoader.java

示例4: testReplaceAclEntriesResultTooLarge

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test(expected=AclException.class)
public void testReplaceAclEntriesResultTooLarge() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayListWithCapacity(32);
  aclSpec.add(aclEntry(ACCESS, USER, ALL));
  for (int i = 1; i <= 29; ++i) {
    aclSpec.add(aclEntry(ACCESS, USER, "user" + i, READ));
  }
  aclSpec.add(aclEntry(ACCESS, GROUP, READ));
  aclSpec.add(aclEntry(ACCESS, OTHER, NONE));
  // The ACL spec now has 32 entries.  Automatic mask calculation will push it
  // over the limit to 33.
  replaceAclEntries(existing, aclSpec);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAclTransformation.java

示例5: testSetPermissionOnlyDefault

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testSetPermissionOnlyDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.setPermission(path, FsPermission.createImmutable((short)0700));
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010700);
  assertAclFeature(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:FSAclBaseTest.java

示例6: write

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
private static void write(List<AclEntry> aclEntries, DataOutputStream out)
    throws IOException {
  if (aclEntries == null) {
    out.writeInt(0);
    return;
  }

  out.writeInt(aclEntries.size());
  for (AclEntry e : aclEntries) {
    boolean hasName = e.getName() != null;
    int v = (e.getScope().ordinal() << ACL_EDITLOG_ENTRY_SCOPE_OFFSET)
        | (e.getType().ordinal() << ACL_EDITLOG_ENTRY_TYPE_OFFSET)
        | e.getPermission().ordinal();

    if (hasName) {
      v |= 1 << ACL_EDITLOG_ENTRY_HAS_NAME_OFFSET;
    }
    out.write(v);
    if (hasName) {
      FSImageSerialization.writeString(e.getName(), out);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:FSEditLogOp.java

示例7: testRemoveAclEntries

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testRemoveAclEntries() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"),
    aclEntry(DEFAULT, USER, "foo"));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:FSAclBaseTest.java

示例8: testToAclStatus

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testToAclStatus() throws IOException {
  String jsonString =
      "{\"AclStatus\":{\"entries\":[\"user::rwx\",\"user:user1:rw-\",\"group::rw-\",\"other::r-x\"],\"group\":\"supergroup\",\"owner\":\"testuser\",\"stickyBit\":false}}";
  ObjectReader reader = new ObjectMapper().reader(Map.class);
  Map<?, ?> json = reader.readValue(jsonString);

  List<AclEntry> aclSpec =
      Lists.newArrayList(aclEntry(ACCESS, USER, ALL),
          aclEntry(ACCESS, USER, "user1", READ_WRITE),
          aclEntry(ACCESS, GROUP, READ_WRITE),
          aclEntry(ACCESS, OTHER, READ_EXECUTE));

  AclStatus.Builder aclStatusBuilder = new AclStatus.Builder();
  aclStatusBuilder.owner("testuser");
  aclStatusBuilder.group("supergroup");
  aclStatusBuilder.addEntries(aclSpec);
  aclStatusBuilder.stickyBit(false);

  Assert.assertEquals("Should be equal", aclStatusBuilder.build(),
      JsonUtil.toAclStatus(json));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestJsonUtil.java

示例9: testMergeAclEntriesAutomaticDefaultOther

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testMergeAclEntriesAutomaticDefaultOther() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, READ_EXECUTE),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .add(aclEntry(DEFAULT, USER, READ_EXECUTE))
    .add(aclEntry(DEFAULT, GROUP, READ_EXECUTE))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestAclTransformation.java

示例10: testReplaceAclEntriesAccessMaskCalculated

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testReplaceAclEntriesAccessMaskCalculated() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "bruce", READ),
    aclEntry(ACCESS, USER, "diana", READ_WRITE),
    aclEntry(ACCESS, GROUP, READ),
    aclEntry(ACCESS, OTHER, READ));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ))
    .add(aclEntry(ACCESS, USER, "diana", READ_WRITE))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ_WRITE))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  assertEquals(expected, replaceAclEntries(existing, aclSpec));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestAclTransformation.java

示例11: testSetAclStickyBit

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testSetAclStickyBit() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)01750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)011770);
  assertAclFeature(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:FSAclBaseTest.java

示例12: testMergeAclEntries

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testMergeAclEntries() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", ALL));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", ALL))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAclTransformation.java

示例13: testRemoveAclEntriesOnlyAccess

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testRemoveAclEntriesOnlyAccess() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, USER, "bar", READ_WRITE),
    aclEntry(ACCESS, GROUP, READ_WRITE),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "bar", READ_WRITE),
    aclEntry(ACCESS, GROUP, READ_WRITE) }, returned);
  assertPermission((short)010760);
  assertAclFeature(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:FSAclBaseTest.java

示例14: testReplaceAclEntriesOnlyDefaults

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test
public void testReplaceAclEntriesOnlyDefaults() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "bruce", READ));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .add(aclEntry(DEFAULT, USER, ALL))
    .add(aclEntry(DEFAULT, USER, "bruce", READ))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, MASK, READ))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  assertEquals(expected, replaceAclEntries(existing, aclSpec));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestAclTransformation.java

示例15: testFilterAclEntriesByAclSpecRemoveDefaultMaskRequired

import org.apache.hadoop.fs.permission.AclEntry; //导入依赖的package包/类
@Test(expected=AclException.class)
public void testFilterAclEntriesByAclSpecRemoveDefaultMaskRequired()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .add(aclEntry(DEFAULT, USER, ALL))
    .add(aclEntry(DEFAULT, USER, "bruce", READ))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, MASK, ALL))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, MASK));
  filterAclEntriesByAclSpec(existing, aclSpec);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestAclTransformation.java


注:本文中的org.apache.hadoop.fs.permission.AclEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。