Search in sources :

Example 71 with Mode

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

the class UfsFileWriteHandler method createUfsFile.

private void createUfsFile(UfsFileWriteRequestContext context) throws IOException {
    UfsFileWriteRequest request = context.getRequest();
    Preconditions.checkState(request != null);
    Protocol.CreateUfsFileOptions createUfsFileOptions = request.getCreateUfsFileOptions();
    UfsManager.UfsClient ufsClient = mUfsManager.get(createUfsFileOptions.getMountId());
    CloseableResource<UnderFileSystem> ufsResource = ufsClient.acquireUfsResource();
    context.setUfsResource(ufsResource);
    UnderFileSystem ufs = ufsResource.get();
    CreateOptions createOptions = CreateOptions.defaults(ServerConfiguration.global()).setCreateParent(true).setOwner(createUfsFileOptions.getOwner()).setGroup(createUfsFileOptions.getGroup()).setMode(new Mode((short) createUfsFileOptions.getMode()));
    if (createUfsFileOptions.hasAcl()) {
        // This acl information will be ignored by all but HDFS implementations
        createOptions.setAcl(ProtoUtils.fromProto(createUfsFileOptions.getAcl()));
    }
    context.setOutputStream(ufs.createNonexistingFile(request.getUfsPath(), createOptions));
    context.setCreateOptions(createOptions);
    String ufsString = MetricsSystem.escape(ufsClient.getUfsMountPointUri());
    MetricKey counterKey = MetricKey.WORKER_BYTES_WRITTEN_UFS;
    MetricKey meterKey = MetricKey.WORKER_BYTES_WRITTEN_UFS_THROUGHPUT;
    context.setCounter(MetricsSystem.counterWithTags(counterKey.getName(), counterKey.isClusterAggregated(), MetricInfo.TAG_UFS, ufsString));
    context.setMeter(MetricsSystem.meterWithTags(meterKey.getName(), meterKey.isClusterAggregated(), MetricInfo.TAG_UFS, ufsString));
}
Also used : MetricKey(alluxio.metrics.MetricKey) UfsManager(alluxio.underfs.UfsManager) Mode(alluxio.security.authorization.Mode) Protocol(alluxio.proto.dataserver.Protocol) UnderFileSystem(alluxio.underfs.UnderFileSystem) CreateOptions(alluxio.underfs.options.CreateOptions)

Example 72 with Mode

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

the class CreateFile method check.

@Override
public void check(FileSystem fs) throws Exception {
    for (AlluxioURI file : Arrays.asList(PATH, NESTED, THROUGH, TTL)) {
        assertTrue(fs.exists(file));
    }
    assertEquals(TEST_MODE, new Mode((short) fs.getStatus(MODE).getMode()));
    assertTrue(fs.getStatus(THROUGH).isPersisted());
    assertEquals(TEST_TTL, fs.getStatus(TTL).getTtl());
    assertEquals(TtlAction.FREE, fs.getStatus(TTL).getTtlAction());
}
Also used : Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI)

Example 73 with Mode

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

the class CreateDirectory method check.

@Override
public void check(FileSystem fs) throws Exception {
    for (AlluxioURI dir : Arrays.asList(DIR, NESTED_DIR, NESTED_NESTED_DIR, RECURSIVE, MODE_DIR, TTL_DIR, COMMON_TTL_DIR, THROUGH_DIR, ALL_OPTS_DIR)) {
        assertTrue(fs.exists(dir));
    }
    assertEquals(TEST_MODE, new Mode((short) fs.getStatus(MODE_DIR).getMode()));
    assertEquals((long) TTL, fs.getStatus(TTL_DIR).getTtl());
    assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(TTL_DIR).getTtlAction());
    assertEquals((long) TTL, fs.getStatus(COMMON_TTL_DIR).getTtl());
    assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(COMMON_TTL_DIR).getTtlAction());
    assertTrue(fs.getStatus(THROUGH_DIR).isPersisted());
    assertEquals(TEST_MODE, new Mode((short) fs.getStatus(ALL_OPTS_DIR).getMode()));
    assertEquals((long) TTL, fs.getStatus(ALL_OPTS_DIR).getTtl());
    assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(ALL_OPTS_DIR).getTtlAction());
    assertTrue(fs.getStatus(ALL_OPTS_DIR).isPersisted());
}
Also used : Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI)

Example 74 with Mode

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

the class UfsJournalIntegrationTest method setAcl.

@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_AUTHENTICATION_TYPE, "SIMPLE", PropertyKey.Name.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "true", PropertyKey.Name.SECURITY_GROUP_MAPPING_CLASS, FakeUserGroupsMapping.FULL_CLASS_NAME })
public void setAcl() throws Exception {
    AlluxioURI filePath = new AlluxioURI("/file");
    String user = "alluxio";
    ServerConfiguration.set(PropertyKey.SECURITY_LOGIN_USERNAME, user);
    CreateFilePOptions op = CreateFilePOptions.newBuilder().setBlockSizeBytes(64).build();
    mFileSystem.createFile(filePath, op).close();
    // TODO(chaomin): also setOwner and setGroup once there's a way to fake the owner/group in UFS.
    mFileSystem.setAttribute(filePath, SetAttributePOptions.newBuilder().setMode(new Mode((short) 0400).toProto()).setRecursive(false).build());
    URIStatus status = mFileSystem.getStatus(filePath);
    mLocalAlluxioCluster.stopFS();
    aclTestUtil(status, user);
    deleteFsMasterJournalLogs();
    aclTestUtil(status, user);
}
Also used : Mode(alluxio.security.authorization.Mode) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 75 with Mode

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

the class AlluxioFuseFileSystemTest 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)

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