Search in sources :

Example 1 with SetAttributePOptions

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;
    });
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions)

Example 2 with SetAttributePOptions

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);
    }
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Mode(alluxio.security.authorization.Mode) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) AlluxioException(alluxio.exception.AlluxioException)

Example 3 with SetAttributePOptions

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);
    }
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 4 with SetAttributePOptions

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;
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI)

Example 5 with SetAttributePOptions

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);
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

SetAttributePOptions (alluxio.grpc.SetAttributePOptions)31 AlluxioURI (alluxio.AlluxioURI)20 Test (org.junit.Test)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 Mode (alluxio.security.authorization.Mode)6 URIStatus (alluxio.client.file.URIStatus)3 ConfigurationRule (alluxio.ConfigurationRule)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 Closeable (java.io.Closeable)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 InvalidPathException (java.nio.file.InvalidPathException)2 FuseContext (ru.serce.jnrfuse.struct.FuseContext)2 FileOutStream (alluxio.client.file.FileOutStream)1 FileSystem (alluxio.client.file.FileSystem)1 AlluxioException (alluxio.exception.AlluxioException)1 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)1 GetStatusPOptions (alluxio.grpc.GetStatusPOptions)1 FuseContext (alluxio.jnifuse.struct.FuseContext)1 JobIntegrationTest (alluxio.job.JobIntegrationTest)1 ListAllMyBucketsResult (alluxio.proxy.s3.ListAllMyBucketsResult)1