use of alluxio.underfs.UfsMode in project alluxio by Alluxio.
the class DefaultFileSystemMaster method checkUfsMode.
/**
* Check if the specified operation type is allowed to the ufs.
*
* @param alluxioPath the Alluxio path
* @param opType the operation type
*/
private void checkUfsMode(AlluxioURI alluxioPath, OperationType opType) throws AccessControlException, InvalidPathException {
MountTable.Resolution resolution = mMountTable.resolve(alluxioPath);
try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
UnderFileSystem ufs = ufsResource.get();
UfsMode ufsMode = ufs.getOperationMode(mUfsManager.getPhysicalUfsState(ufs.getPhysicalStores()));
switch(ufsMode) {
case NO_ACCESS:
throw new AccessControlException(ExceptionMessage.UFS_OP_NOT_ALLOWED.getMessage(opType, resolution.getUri(), UfsMode.NO_ACCESS));
case READ_ONLY:
if (opType == OperationType.WRITE) {
throw new AccessControlException(ExceptionMessage.UFS_OP_NOT_ALLOWED.getMessage(opType, resolution.getUri(), UfsMode.READ_ONLY));
}
break;
default:
// All operations are allowed
break;
}
}
}
use of alluxio.underfs.UfsMode in project alluxio by Alluxio.
the class FileSystemMasterClientServiceHandler method updateUfsMode.
@Override
public void updateUfsMode(UpdateUfsModePRequest request, StreamObserver<UpdateUfsModePResponse> responseObserver) {
RpcUtils.call(LOG, () -> {
UfsMode ufsMode;
switch(request.getOptions().getUfsMode()) {
case NO_ACCESS:
ufsMode = UfsMode.NO_ACCESS;
break;
case READ_ONLY:
ufsMode = UfsMode.READ_ONLY;
break;
default:
ufsMode = UfsMode.READ_WRITE;
break;
}
mFileSystemMaster.updateUfsMode(new AlluxioURI(request.getUfsPath()), ufsMode);
return UpdateUfsModePResponse.newBuilder().build();
}, "UpdateUfsMode", "request=%s", responseObserver, request);
}
Aggregations