use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method createDirectory.
@Override
public long createDirectory(AlluxioURI path, CreateDirectoryContext context) throws InvalidPathException, FileAlreadyExistsException, IOException, AccessControlException, FileDoesNotExistException {
if (isOperationComplete(context)) {
Metrics.COMPLETED_OPERATION_RETRIED_COUNT.inc();
LOG.warn("A completed \"createDirectory\" operation has been retried. {}", context);
return getFileInfo(path, GetStatusContext.create(GetStatusPOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(-1)).setLoadMetadataType(LoadMetadataPType.NEVER).setUpdateTimestamps(false))).getFileId();
}
Metrics.CREATE_DIRECTORIES_OPS.inc();
try (RpcContext rpcContext = createRpcContext(context);
FileSystemMasterAuditContext auditContext = createAuditContext("mkdir", path, null, null)) {
syncMetadata(rpcContext, path, context.getOptions().getCommonOptions(), DescendantType.ONE, auditContext, inodePath -> context.getOptions().getRecursive() ? inodePath.getLastExistingInode() : inodePath.getParentInodeOrNull(), (inodePath, permChecker) -> permChecker.checkParentPermission(Mode.Bits.WRITE, inodePath), false);
LockingScheme lockingScheme = createLockingScheme(path, context.getOptions().getCommonOptions(), LockPattern.WRITE_EDGE);
try (LockedInodePath inodePath = mInodeTree.lockInodePath(lockingScheme)) {
auditContext.setSrcInode(inodePath.getParentInodeOrNull());
if (context.getOptions().getRecursive()) {
auditContext.setSrcInode(inodePath.getLastExistingInode());
}
try {
mPermissionChecker.checkParentPermission(Mode.Bits.WRITE, inodePath);
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
mMountTable.checkUnderWritableMountPoint(path);
if (context.isPersisted()) {
checkUfsMode(path, OperationType.WRITE);
}
createDirectoryInternal(rpcContext, inodePath, context);
auditContext.setSrcInode(inodePath.getInode()).setSucceeded(true);
cacheOperation(context);
return inodePath.getInode().getId();
}
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method checkConsistency.
@Override
public List<AlluxioURI> checkConsistency(AlluxioURI path, CheckConsistencyContext context) throws AccessControlException, FileDoesNotExistException, InvalidPathException, IOException {
List<AlluxioURI> inconsistentUris = new ArrayList<>();
try (RpcContext rpcContext = createRpcContext(context);
FileSystemMasterAuditContext auditContext = createAuditContext("checkConsistency", path, null, null)) {
InodeSyncStream.SyncStatus syncStatus = syncMetadata(rpcContext, path, context.getOptions().getCommonOptions(), DescendantType.ALL, auditContext, LockedInodePath::getInodeOrNull, (inodePath, permChecker) -> permChecker.checkPermission(Mode.Bits.READ, inodePath), false);
LockingScheme lockingScheme = createLockingScheme(path, context.getOptions().getCommonOptions(), LockPattern.READ);
try (LockedInodePath parent = mInodeTree.lockInodePath(lockingScheme.getPath(), lockingScheme.getPattern())) {
auditContext.setSrcInode(parent.getInodeOrNull());
try {
mPermissionChecker.checkPermission(Mode.Bits.READ, parent);
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
checkConsistencyRecursive(parent, inconsistentUris, false, syncStatus == OK);
auditContext.setSucceeded(true);
}
}
return inconsistentUris;
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method updateMount.
@Override
public void updateMount(AlluxioURI alluxioPath, MountContext context) throws FileAlreadyExistsException, FileDoesNotExistException, InvalidPathException, IOException, AccessControlException {
LockingScheme lockingScheme = createLockingScheme(alluxioPath, context.getOptions().getCommonOptions(), LockPattern.WRITE_EDGE);
try (RpcContext rpcContext = createRpcContext(context);
LockedInodePath inodePath = mInodeTree.lockInodePath(lockingScheme.getPath(), lockingScheme.getPattern());
FileSystemMasterAuditContext auditContext = createAuditContext("updateMount", alluxioPath, null, inodePath.getParentInodeOrNull())) {
try {
mPermissionChecker.checkParentPermission(Mode.Bits.WRITE, inodePath);
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
MountInfo mountInfo = mMountTable.getMountTable().get(alluxioPath.getPath());
if (mountInfo == null) {
throw new InvalidPathException("Failed to update mount properties for " + inodePath.getUri() + ". Please ensure the path is an existing mount point.");
}
updateMountInternal(rpcContext, inodePath, mountInfo.getUfsUri(), mountInfo, context);
auditContext.setSucceeded(true);
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method startSync.
@Override
public void startSync(AlluxioURI syncPoint) throws IOException, InvalidPathException, AccessControlException, ConnectionFailedException {
LockingScheme lockingScheme = new LockingScheme(syncPoint, LockPattern.WRITE_EDGE, true);
try (RpcContext rpcContext = createRpcContext();
LockedInodePath inodePath = mInodeTree.lockInodePath(lockingScheme.getPath(), lockingScheme.getPattern());
FileSystemMasterAuditContext auditContext = createAuditContext("startSync", syncPoint, null, inodePath.getParentInodeOrNull())) {
try {
mPermissionChecker.checkParentPermission(Mode.Bits.WRITE, inodePath);
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
mSyncManager.startSyncAndJournal(rpcContext, syncPoint);
auditContext.setSucceeded(true);
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method unmount.
@Override
public void unmount(AlluxioURI alluxioPath) throws FileDoesNotExistException, InvalidPathException, IOException, AccessControlException {
Metrics.UNMOUNT_OPS.inc();
// Unmount should lock the parent to remove the child inode.
try (RpcContext rpcContext = createRpcContext();
LockedInodePath inodePath = mInodeTree.lockInodePath(alluxioPath, LockPattern.WRITE_EDGE);
FileSystemMasterAuditContext auditContext = createAuditContext("unmount", alluxioPath, null, inodePath.getInodeOrNull())) {
try {
mPermissionChecker.checkParentPermission(Mode.Bits.WRITE, inodePath);
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
unmountInternal(rpcContext, inodePath);
auditContext.setSucceeded(true);
Metrics.PATHS_UNMOUNTED.inc();
}
}
Aggregations