org.apache.hadoop.hdfs.protocol.AclException Java Examples

The following examples show how to use org.apache.hadoop.hdfs.protocol.AclException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #2
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #3
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesAccessMaskCalculated() throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, USER, "diana", READ));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_EXECUTE))
    .add(aclEntry(ACCESS, USER, "diana", READ))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #4
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecAccessMaskCalculated()
    throws AclException {
  List<AclEntry> existing = 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();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "diana"));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  assertEquals(expected, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #5
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecEmptyAclSpec() 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))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, ALL))
    .add(aclEntry(DEFAULT, USER, "bruce", READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, MASK, ALL))
    .add(aclEntry(DEFAULT, OTHER, READ))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList();
  assertEquals(existing, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #6
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(expected=AclException.class)
public void testMergeAclEntriesResultTooLarge() throws AclException {
  ImmutableList.Builder<AclEntry> aclBuilder =
    new ImmutableList.Builder<AclEntry>()
      .add(aclEntry(ACCESS, USER, ALL));
  for (int i = 1; i <= 28; ++i) {
    aclBuilder.add(aclEntry(ACCESS, USER, "user" + i, READ));
  }
  aclBuilder
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ))
    .add(aclEntry(ACCESS, OTHER, NONE));
  List<AclEntry> existing = aclBuilder.build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", READ));
  mergeAclEntries(existing, aclSpec);
}
 
Example #7
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecAutomaticDefaultGroup()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, GROUP));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  assertEquals(expected, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #8
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecAutomaticDefaultOther()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, OTHER));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, READ))
    .build();
  assertEquals(expected, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #9
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecEmptyAclSpec() 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))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, ALL))
    .add(aclEntry(DEFAULT, USER, "bruce", READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, MASK, ALL))
    .add(aclEntry(DEFAULT, OTHER, READ))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList();
  assertEquals(existing, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #10
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #12
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #13
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesMultipleNewBeforeExisting()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "diana", READ))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, USER, "clark", READ_EXECUTE),
    aclEntry(ACCESS, USER, "diana", READ_EXECUTE));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_EXECUTE))
    .add(aclEntry(ACCESS, USER, "clark", READ_EXECUTE))
    .add(aclEntry(ACCESS, USER, "diana", READ_EXECUTE))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #14
Source File: FSDirMkdirOp.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * create a directory at path specified by parent
 */
private static INodesInPath unprotectedMkdir(FSDirectory fsd, long inodeId,
    INodesInPath parent, byte[] name, PermissionStatus permission,
    List<AclEntry> aclEntries, long timestamp)
    throws QuotaExceededException, AclException, FileAlreadyExistsException {
  assert fsd.hasWriteLock();
  assert parent.getLastINode() != null;
  if (!parent.getLastINode().isDirectory()) {
    throw new FileAlreadyExistsException("Parent path is not a directory: " +
        parent.getPath() + " " + DFSUtil.bytes2String(name));
  }
  final INodeDirectory dir = new INodeDirectory(inodeId, name, permission,
      timestamp);

  INodesInPath iip = fsd.addLastINode(parent, dir, true);
  if (iip != null && aclEntries != null) {
    AclStorage.updateINodeAcl(dir, aclEntries, Snapshot.CURRENT_STATE_ID);
  }
  return iip;
}
 
Example #15
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesAutomaticDefaultGroup() 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(DEFAULT, USER, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, READ));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_EXECUTE))
    .add(aclEntry(DEFAULT, GROUP, READ))
    .add(aclEntry(DEFAULT, OTHER, READ))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #16
Source File: DFSClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public void removeAclEntries(String src, List<AclEntry> aclSpec)
    throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeAclEntries", traceSampler);
  try {
    namenode.removeAclEntries(src, aclSpec);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   AclException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
Example #17
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesProvidedAccessMask() 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(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, MASK, ALL));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_EXECUTE))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, ALL))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #18
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesProvidedDefaultMask() 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, ALL),
    aclEntry(DEFAULT, GROUP, READ),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE));
  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, GROUP, READ))
    .add(aclEntry(DEFAULT, MASK, ALL))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #19
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #20
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(expected=AclException.class)
public void testMergeAclEntriesResultTooLarge() throws AclException {
  ImmutableList.Builder<AclEntry> aclBuilder =
    new ImmutableList.Builder<AclEntry>()
      .add(aclEntry(ACCESS, USER, ALL));
  for (int i = 1; i <= 28; ++i) {
    aclBuilder.add(aclEntry(ACCESS, USER, "user" + i, READ));
  }
  aclBuilder
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ))
    .add(aclEntry(ACCESS, OTHER, NONE));
  List<AclEntry> existing = aclBuilder.build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", READ));
  mergeAclEntries(existing, aclSpec);
}
 
Example #21
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecAccessMaskCalculated()
    throws AclException {
  List<AclEntry> existing = 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();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "diana"));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, MASK, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .build();
  assertEquals(expected, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #22
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #23
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterAclEntriesByAclSpecAutomaticDefaultOther()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, OTHER));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, GROUP, READ))
    .add(aclEntry(ACCESS, OTHER, READ))
    .add(aclEntry(DEFAULT, USER, READ_WRITE))
    .add(aclEntry(DEFAULT, GROUP, READ_WRITE))
    .add(aclEntry(DEFAULT, OTHER, READ))
    .build();
  assertEquals(expected, filterAclEntriesByAclSpec(existing, aclSpec));
}
 
Example #24
Source File: TestAclTransformation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #25
Source File: HDFSExceptionHelpers.java    From pravega with Apache License 2.0 6 votes vote down vote up
/**
 * Translates HDFS specific Exceptions to Pravega-equivalent Exceptions.
 *
 * @param segmentName Name of the stream segment on which the exception occurs.
 * @param e           The exception to be translated.
 * @return  The exception to be thrown.
 */
static <T> StreamSegmentException convertException(String segmentName, Throwable e) {
    if (e instanceof RemoteException) {
        e = ((RemoteException) e).unwrapRemoteException();
    }

    if (e instanceof PathNotFoundException || e instanceof FileNotFoundException) {
        return new StreamSegmentNotExistsException(segmentName, e);
    } else if (e instanceof FileAlreadyExistsException || e instanceof AlreadyBeingCreatedException) {
        return new StreamSegmentExistsException(segmentName, e);
    } else if (e instanceof AclException) {
        return new StreamSegmentSealedException(segmentName, e);
    } else {
        throw Exceptions.sneakyThrow(e);
    }
}
 
Example #26
Source File: DFSClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void modifyAclEntries(String src, List<AclEntry> aclSpec)
    throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("modifyAclEntries", src);
  try {
    namenode.modifyAclEntries(src, aclSpec);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   AclException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
Example #27
Source File: DFSClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void removeDefaultAcl(String src) throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeDefaultAcl", traceSampler);
  try {
    namenode.removeDefaultAcl(src);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   AclException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
Example #28
Source File: DFSClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void removeAcl(String src) throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeAcl", traceSampler);
  try {
    namenode.removeAcl(src);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   AclException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
Example #29
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testMergeAclEntriesMultipleNewBeforeExisting()
    throws AclException {
  List<AclEntry> existing = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "diana", READ))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, USER, "clark", READ_EXECUTE),
    aclEntry(ACCESS, USER, "diana", READ_EXECUTE));
  List<AclEntry> expected = new ImmutableList.Builder<AclEntry>()
    .add(aclEntry(ACCESS, USER, ALL))
    .add(aclEntry(ACCESS, USER, "bruce", READ_EXECUTE))
    .add(aclEntry(ACCESS, USER, "clark", READ_EXECUTE))
    .add(aclEntry(ACCESS, USER, "diana", READ_EXECUTE))
    .add(aclEntry(ACCESS, GROUP, READ_EXECUTE))
    .add(aclEntry(ACCESS, MASK, READ_EXECUTE))
    .add(aclEntry(ACCESS, OTHER, NONE))
    .build();
  assertEquals(expected, mergeAclEntries(existing, aclSpec));
}
 
Example #30
Source File: TestAclTransformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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);
}