Java Code Examples for org.apache.hadoop.fs.permission.FsAction#READ

The following examples show how to use org.apache.hadoop.fs.permission.FsAction#READ . 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: SentryPermissions.java    From incubator-sentry with Apache License 2.0 6 votes vote down vote up
@Override
public List<AclEntry> getAcls(String authzObj) {
  Map<String, FsAction> groupPerms = getGroupPerms(authzObj);
  List<AclEntry> retList = new LinkedList<AclEntry>();
  for (Map.Entry<String, FsAction> groupPerm : groupPerms.entrySet()) {
    AclEntry.Builder builder = new AclEntry.Builder();
    builder.setName(groupPerm.getKey());
    builder.setType(AclEntryType.GROUP);
    builder.setScope(AclEntryScope.ACCESS);
    FsAction action = groupPerm.getValue();
    if (action == FsAction.READ || action == FsAction.WRITE
        || action == FsAction.READ_WRITE) {
      action = action.or(FsAction.EXECUTE);
    }
    builder.setPermission(action);
    retList.add(builder.build());
  }
  return retList;
}
 
Example 2
Source File: TestBlobMetadata.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testFolderMetadata() throws Exception {
  Path folder = new Path("/folder");
  FsPermission justRead = new FsPermission(FsAction.READ, FsAction.READ,
      FsAction.READ);
  fs.mkdirs(folder, justRead);
  HashMap<String, String> metadata = backingStore
      .getMetadata(AzureBlobStorageTestAccount.toMockUri(folder));
  assertNotNull(metadata);
  assertEquals("true", metadata.get("hdi_isfolder"));
  assertEquals(getExpectedPermissionString("r--r--r--"),
      metadata.get("hdi_permission"));
}
 
Example 3
Source File: TestBlobMetadata.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testFolderMetadata() throws Exception {
  Path folder = new Path("/folder");
  FsPermission justRead = new FsPermission(FsAction.READ, FsAction.READ,
      FsAction.READ);
  fs.mkdirs(folder, justRead);
  HashMap<String, String> metadata = backingStore
      .getMetadata(AzureBlobStorageTestAccount.toMockUri(folder));
  assertNotNull(metadata);
  assertEquals("true", metadata.get("hdi_isfolder"));
  assertEquals(getExpectedPermissionString("r--r--r--"),
      metadata.get("hdi_permission"));
}
 
Example 4
Source File: MockFileSystem.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {
    FileData data = getFileData(f);
    if (data.getStatus().getPermission().getUserAction() == FsAction.READ) {
        throw HDFSExceptionHelpers.segmentSealedException(f.getName());
    }

    return new FSDataOutputStream(data.contents, null, data.contents.size());
}
 
Example 5
Source File: HDFSStorageTest.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {
    if (getFileStatus(f).getPermission().getUserAction() == FsAction.READ) {
        throw new AclException(f.getName());
    }

    return super.append(f, bufferSize, progress);
}
 
Example 6
Source File: HDFSStorageTest.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public void concat(Path targetPath, Path[] sourcePaths) throws IOException {
    if (getFileStatus(targetPath).getPermission().getUserAction() == FsAction.READ) {
        throw new AclException(targetPath.getName());
    }

    super.concat(targetPath, sourcePaths);
}
 
Example 7
Source File: MetricsFileSystemInstrumentationTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Test(enabled = false)
public void testCreate7() throws IOException, URISyntaxException {
  HDFSRoot hdfsRoot = new HDFSRoot("/tmp/create");
  MetricsFileSystemInstrumentation
      fs = (MetricsFileSystemInstrumentation) FileSystem.get(new URI(instrumentedURI), new Configuration());
  FsPermission permission = new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.READ);
  Path newFile = new Path("/tmp/create/newFile");
  FSDataOutputStream fstream = fs.create(newFile, permission, true, 100, (short)2, 1048576, null);
  Assert.assertEquals(fs.createTimer.getCount(), 1);
  fstream.close();
  hdfsRoot.cleanupRoot();
}
 
Example 8
Source File: MetricsFileSystemInstrumentationTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Test(enabled = false)
public void testSetPermission() throws IOException, URISyntaxException {
  HDFSRoot hdfsRoot = new HDFSRoot("/tmp/permission");
  MetricsFileSystemInstrumentation
      fs = (MetricsFileSystemInstrumentation) FileSystem.get(new URI(instrumentedURI), new Configuration());
  FsPermission permission = new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.READ);
  fs.setPermission(hdfsRoot.getFilePath8(), permission);
  Assert.assertEquals(fs.setPermissionTimer.getCount(), 1);
  hdfsRoot.cleanupRoot();
}
 
Example 9
Source File: HDFSStorage.java    From pravega with Apache License 2.0 2 votes vote down vote up
/**
 * Determines whether the given FileStatus indicates the file is read-only.
 *
 * @param fs The FileStatus to check.
 * @return True or false.
 */
private boolean isReadOnly(FileStatus fs) {
    return fs.getPermission().getUserAction() == FsAction.READ;
}