Search in sources :

Example 51 with AccessControlException

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();
        }
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) LockingScheme(alluxio.master.file.meta.LockingScheme) AccessControlException(alluxio.exception.AccessControlException)

Example 52 with AccessControlException

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;
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) LockingScheme(alluxio.master.file.meta.LockingScheme) ArrayList(java.util.ArrayList) AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI)

Example 53 with AccessControlException

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);
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) LockingScheme(alluxio.master.file.meta.LockingScheme) AccessControlException(alluxio.exception.AccessControlException) MountInfo(alluxio.master.file.meta.options.MountInfo) InvalidPathException(alluxio.exception.InvalidPathException)

Example 54 with AccessControlException

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);
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) LockingScheme(alluxio.master.file.meta.LockingScheme) AccessControlException(alluxio.exception.AccessControlException)

Example 55 with AccessControlException

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();
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) AccessControlException(alluxio.exception.AccessControlException)

Aggregations

AccessControlException (alluxio.exception.AccessControlException)64 AlluxioURI (alluxio.AlluxioURI)29 LockedInodePath (alluxio.master.file.meta.LockedInodePath)21 Test (org.junit.Test)21 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)16 LockingScheme (alluxio.master.file.meta.LockingScheme)15 InvalidPathException (alluxio.exception.InvalidPathException)12 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 Inode (alluxio.master.file.meta.Inode)9 MountTable (alluxio.master.file.meta.MountTable)7 FileInfo (alluxio.wire.FileInfo)7 AlluxioException (alluxio.exception.AlluxioException)4 LockedInodePathList (alluxio.master.file.meta.LockedInodePathList)4 Mode (alluxio.security.authorization.Mode)4 UnderFileSystem (alluxio.underfs.UnderFileSystem)4 FileBlockInfo (alluxio.wire.FileBlockInfo)4 DescendantType (alluxio.file.options.DescendantType)3 FileSystemMasterCommonPOptions (alluxio.grpc.FileSystemMasterCommonPOptions)3