List of usage examples for org.apache.hadoop.fs FileSystem modifyAclEntries
public void modifyAclEntries(Path path, List<AclEntry> aclSpec) throws IOException
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * {@inheritDoc}/*from ww w . j a va 2 s . c o m*/ */ @Override public void modifyAclEntries(Path path, final List<AclEntry> aclSpec) throws IOException { Path absF = fixRelativePart(path); new FileSystemLinkResolver<Void>() { @Override public Void doCall(final Path p) throws IOException { dfs.modifyAclEntries(getPathName(p), aclSpec); return null; } @Override public Void next(final FileSystem fs, final Path p) throws IOException { fs.modifyAclEntries(p, aclSpec); return null; } }.resolve(this, absF); }
From source file:com.thinkbiganalytics.datalake.authorization.hdfs.HDFSUtil.java
License:Apache License
/** * @param fileSystem : HDFS FileSystem Object * @param path : HDFS Path/*from w w w. j av a 2 s . c o m*/ * @param aclEntry : ACL for HDFS Path */ public void applyAcl(FileSystem fileSystem, Path path, AclEntry aclEntry) throws IOException { try { fileSystem.modifyAclEntries(path, Lists.newArrayList(aclEntry)); } catch (IOException e) { log.error("Unable to apply HDFS Policy for " + path.toString() + " " + e.getMessage()); throw new IOException(e); } }
From source file:org.trafodion.sql.HBaseAccess.HBaseClient.java
License:Apache License
private boolean updatePermissionForEntries(FileStatus[] entries, String hbaseUser, FileSystem fs) throws IOException { if (entries == null) { return true; }/*www .j a v a 2 s. co m*/ for (FileStatus child : entries) { Path path = child.getPath(); List<AclEntry> lacl = AclEntry.parseAclSpec("user:" + hbaseUser + ":rwx", true); try { fs.modifyAclEntries(path, lacl); } catch (IOException e) { //if failure just log exception and continue if (logger.isTraceEnabled()) logger.trace("[Snapshot Scan] SnapshotScanHelper.updatePermissionForEntries() exception. " + e); } if (child.isDir()) { FileStatus[] files = FSUtils.listStatus(fs, path); updatePermissionForEntries(files, hbaseUser, fs); } } return true; }
From source file:org.trafodion.sql.HBaseAccess.HBaseClient.java
License:Apache License
public boolean setArchivePermissions(String tabName) throws IOException, ServiceException { if (logger.isTraceEnabled()) logger.trace("[Snapshot Scan] SnapshotScanHelper.setArchivePermissions() called. "); Path rootDir = FSUtils.getRootDir(config); FileSystem myfs = FileSystem.get(rootDir.toUri(), config); FileStatus fstatus = myfs.getFileStatus(rootDir); String hbaseUser = fstatus.getOwner(); assert (hbaseUser != null && hbaseUser.length() != 0); Path tabArcPath = HFileArchiveUtil.getTableArchivePath(config, TableName.valueOf(tabName)); if (tabArcPath == null) return true; List<AclEntry> lacl = AclEntry.parseAclSpec("user:" + hbaseUser + ":rwx", true); try {//from ww w. j av a 2 s.co m myfs.modifyAclEntries(tabArcPath, lacl); } catch (IOException e) { //if failure just log exception and continue if (logger.isTraceEnabled()) logger.trace("[Snapshot Scan] SnapshotScanHelper.setArchivePermissions() exception. " + e); } FileStatus[] files = FSUtils.listStatus(myfs, tabArcPath); updatePermissionForEntries(files, hbaseUser, myfs); return true; }
From source file:org.trustedanalytics.samples.services.HdfsService.java
License:Apache License
/** * Create directory inside file system./*w w w . j ava2 s.c o m*/ * * @param fs configured Hadoop FileSystem * @param filePath path to the directory * @return path to the directory @throws IOException io exception */ private Path createDirectory(FileSystem fs, String filePath) throws IOException { Path path = new Path(filePath); fs.mkdirs(path); fs.setPermission(path, FsPermission.valueOf("drwxrwxrwx")); fs.modifyAclEntries(path, FsPermissionHelper .getDefaultAclsForTechnicalUsers(FsPermissionHelper.getToolUsers(), FsAction.ALL)); fs.modifyAclEntries(path, FsPermissionHelper.getAclsForTechnicalUsers(FsPermissionHelper.getToolUsers(), FsAction.ALL)); return fs.getFileStatus(path).getPath(); }