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));
}
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());
}
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());
}
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);
}
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);
}
Aggregations