use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class BaseFileSystem method setAttribute.
@Override
public void setAttribute(AlluxioURI path, SetAttributePOptions options) throws FileDoesNotExistException, IOException, AlluxioException {
checkUri(path);
SetAttributePOptions mergedOptions = FileSystemOptions.setAttributeClientDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
rpc(client -> {
client.setAttribute(path, mergedOptions);
LOG.debug("Set attributes for {}, options: {}", path.getPath(), options);
return null;
});
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AbstractFileSystem method setPermission.
/**
* Changes permission of a path.
*
* @param path path to set permission
* @param permission permission set to path
*/
@Override
public void setPermission(Path path, FsPermission permission) throws IOException {
LOG.debug("setMode({},{})", path, permission);
AlluxioURI uri = getAlluxioPath(path);
SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(new Mode(permission.toShort()).toProto()).setRecursive(false).build();
try {
mFileSystem.setAttribute(uri, options);
} catch (AlluxioException e) {
throw new IOException(e);
}
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class PermissionCheckTest method setStateFail.
@Test
public void setStateFail() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
String file = PathUtils.concatPath(TEST_DIR_URI, "testState1");
verifyCreateFile(TEST_USER_1, file, false);
SetAttributePOptions expect = getNonDefaultSetState();
mThrown.expect(AccessControlException.class);
mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testState1")));
verifySetState(TEST_USER_2, file, expect);
}
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AlluxioJniFuseFileSystem method chmodInternal.
private int chmodInternal(String path, long mode) {
AlluxioURI uri = mPathResolverCache.getUnchecked(path);
SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(new Mode((short) mode).toProto()).build();
try {
mFileSystem.setAttribute(uri, options);
} catch (Throwable t) {
LOG.error("Failed to change {} to mode {}", path, mode, t);
return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AlluxioJniFuseFileSystemTest method chownWithoutValidGid.
@Test
public void chownWithoutValidGid() throws Exception {
long uid = AlluxioFuseUtils.getUid(System.getProperty("user.name"));
long gid = AlluxioFuseUtils.ID_NOT_SET_VALUE;
mFuseFs.chown("/foo/bar", uid, gid);
String userName = System.getProperty("user.name");
String groupName = AlluxioFuseUtils.getGroupName(userName);
AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
SetAttributePOptions options = SetAttributePOptions.newBuilder().setGroup(groupName).setOwner(userName).build();
verify(mFileSystem).setAttribute(expectedPath, options);
gid = AlluxioFuseUtils.ID_NOT_SET_VALUE_UNSIGNED;
mFuseFs.chown("/foo/bar", uid, gid);
verify(mFileSystem, times(2)).setAttribute(expectedPath, options);
}
Aggregations