Search in sources :

Example 76 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class AlluxioJniFuseFileSystemTest method chmod.

@Test
public void chmod() throws Exception {
    long mode = 123;
    mFuseFs.chmod("/foo/bar", mode);
    AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
    SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(new Mode((short) mode).toProto()).build();
    verify(mFileSystem).setAttribute(expectedPath, options);
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 77 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class AlluxioJniFuseFileSystem method mkdirInternal.

private int mkdirInternal(String path, long mode) {
    final AlluxioURI uri = mPathResolverCache.getUnchecked(path);
    if (uri.getName().length() > MAX_NAME_LENGTH) {
        LOG.error("Failed to create directory {}: name longer than {} characters", path, MAX_NAME_LENGTH);
        return -ErrorCodes.ENAMETOOLONG();
    }
    try {
        mFileSystem.createDirectory(uri, CreateDirectoryPOptions.newBuilder().setMode(new Mode((short) mode).toProto()).build());
        mAuthPolicy.setUserGroupIfNeeded(uri);
    } catch (Throwable e) {
        LOG.error("Failed to mkdir {}: ", path, e);
        return -ErrorCodes.EIO();
    }
    return 0;
}
Also used : Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI)

Example 78 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class AlluxioJniFuseFileSystem method createInternal.

private int createInternal(String path, long mode, FuseFileInfo fi) {
    final AlluxioURI uri = mPathResolverCache.getUnchecked(path);
    if (uri.getName().length() > MAX_NAME_LENGTH) {
        LOG.error("Failed to create {}: file name longer than {} characters", path, MAX_NAME_LENGTH);
        return -ErrorCodes.ENAMETOOLONG();
    }
    try {
        FileOutStream os = mFileSystem.createFile(uri, CreateFilePOptions.newBuilder().setMode(new Mode((short) mode).toProto()).build());
        long fid = mNextOpenFileId.getAndIncrement();
        mCreateFileEntries.add(new CreateFileEntry(fid, path, os));
        fi.fh.set(fid);
        mAuthPolicy.setUserGroupIfNeeded(uri);
    } catch (Throwable e) {
        LOG.error("Failed to create {}: ", path, e);
        return -ErrorCodes.EIO();
    }
    return 0;
}
Also used : Mode(alluxio.security.authorization.Mode) FileOutStream(alluxio.client.file.FileOutStream) AlluxioURI(alluxio.AlluxioURI)

Aggregations

Mode (alluxio.security.authorization.Mode)78 Test (org.junit.Test)47 AlluxioURI (alluxio.AlluxioURI)43 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)15 UnderFileSystem (alluxio.underfs.UnderFileSystem)14 Random (java.util.Random)14 IOException (java.io.IOException)11 UfsMode (alluxio.underfs.UfsMode)9 URIStatus (alluxio.client.file.URIStatus)8 FileInfo (alluxio.wire.FileInfo)8 ArrayList (java.util.ArrayList)8 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)7 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 WriteType (alluxio.client.WriteType)5 AlluxioException (alluxio.exception.AlluxioException)5 LockedInodePath (alluxio.master.file.meta.LockedInodePath)5 AclEntry (alluxio.security.authorization.AclEntry)5 AuthenticatedClientUserResource (alluxio.AuthenticatedClientUserResource)4 AuthenticatedUserRule (alluxio.AuthenticatedUserRule)4