use of alluxio.master.file.meta.LockingScheme in project alluxio by Alluxio.
the class DefaultFileSystemMaster method loadMetadataIfNotExist.
/**
* Loads metadata for the path if it is (non-existing || load direct children is set).
*
* See {@link #shouldLoadMetadataIfNotExists(LockedInodePath, LoadMetadataContext)}.
*
* @param rpcContext the rpc context
* @param path the path to load metadata for
* @param context the {@link LoadMetadataContext}
* @param isGetFileInfo whether this is loading for a {@link #getFileInfo} call
*/
private void loadMetadataIfNotExist(RpcContext rpcContext, AlluxioURI path, LoadMetadataContext context, boolean isGetFileInfo) throws InvalidPathException, AccessControlException {
DescendantType syncDescendantType = GrpcUtils.fromProto(context.getOptions().getLoadDescendantType());
FileSystemMasterCommonPOptions commonOptions = context.getOptions().getCommonOptions();
boolean loadAlways = context.getOptions().hasLoadType() && (context.getOptions().getLoadType().equals(LoadMetadataPType.ALWAYS));
// load metadata only and force sync
InodeSyncStream sync = new InodeSyncStream(new LockingScheme(path, LockPattern.READ, false), this, rpcContext, syncDescendantType, commonOptions, isGetFileInfo, true, true, loadAlways);
if (sync.sync().equals(FAILED)) {
LOG.debug("Failed to load metadata for path from UFS: {}", path);
}
}
use of alluxio.master.file.meta.LockingScheme in project alluxio by Alluxio.
the class DefaultFileSystemMaster method delete.
@Override
public void delete(AlluxioURI path, DeleteContext context) throws IOException, FileDoesNotExistException, DirectoryNotEmptyException, InvalidPathException, AccessControlException {
if (isOperationComplete(context)) {
Metrics.COMPLETED_OPERATION_RETRIED_COUNT.inc();
LOG.warn("A completed \"delete\" operation has been retried. {}", context);
return;
}
Metrics.DELETE_PATHS_OPS.inc();
try (RpcContext rpcContext = createRpcContext(context);
FileSystemMasterAuditContext auditContext = createAuditContext("delete", path, null, null)) {
if (context.getOptions().getAlluxioOnly()) {
LOG.debug("alluxio-only deletion on path {} skips metadata sync", path);
} else {
syncMetadata(rpcContext, path, context.getOptions().getCommonOptions(), context.getOptions().getRecursive() ? DescendantType.ALL : DescendantType.ONE, auditContext, LockedInodePath::getInodeOrNull, (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)) {
mPermissionChecker.checkParentPermission(Mode.Bits.WRITE, inodePath);
if (context.getOptions().getRecursive()) {
List<String> failedChildren = new ArrayList<>();
try (LockedInodePathList descendants = mInodeTree.getDescendants(inodePath)) {
for (LockedInodePath childPath : descendants) {
try {
mPermissionChecker.checkPermission(Mode.Bits.WRITE, childPath);
if (mMountTable.isMountPoint(childPath.getUri())) {
mMountTable.checkUnderWritableMountPoint(childPath.getUri());
}
} catch (AccessControlException e) {
failedChildren.add(e.getMessage());
}
}
if (failedChildren.size() > 0) {
throw new AccessControlException(ExceptionMessage.DELETE_FAILED_DIR_CHILDREN.getMessage(path, StringUtils.join(failedChildren, ",")));
}
} catch (AccessControlException e) {
auditContext.setAllowed(false);
throw e;
}
}
mMountTable.checkUnderWritableMountPoint(path);
if (!inodePath.fullPathExists()) {
throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(path));
}
deleteInternal(rpcContext, inodePath, context);
auditContext.setSucceeded(true);
cacheOperation(context);
}
}
}
Aggregations