use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CompleteUfsFileOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() throws IOException {
Random random = new Random();
String owner = CommonUtils.randomAlphaNumString(10);
String group = CommonUtils.randomAlphaNumString(10);
Mode mode = new Mode((short) random.nextInt());
CompleteUfsFileOptions options = CompleteUfsFileOptions.defaults();
options.setOwner(owner);
options.setGroup(group);
options.setMode(mode);
Assert.assertEquals(owner, options.getOwner());
Assert.assertEquals(group, options.getGroup());
Assert.assertEquals(mode, options.getMode());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CreateDirectoryOptionsTest method toThrift.
/**
* Tests conversion to thrift representation.
*/
@Test
public void toThrift() {
Random random = new Random();
boolean allowExists = random.nextBoolean();
boolean recursive = random.nextBoolean();
Mode mode = new Mode((short) random.nextInt());
long ttl = random.nextLong();
WriteType writeType = WriteType.NONE;
CreateDirectoryOptions options = CreateDirectoryOptions.defaults();
options.setAllowExists(allowExists);
options.setMode(mode);
options.setTtl(ttl);
options.setTtlAction(TtlAction.FREE);
options.setRecursive(recursive);
options.setWriteType(writeType);
CreateDirectoryTOptions thriftOptions = options.toThrift();
Assert.assertEquals(allowExists, thriftOptions.isAllowExists());
Assert.assertEquals(recursive, thriftOptions.isRecursive());
Assert.assertEquals(writeType.isThrough(), thriftOptions.isPersisted());
Assert.assertEquals(ttl, thriftOptions.getTtl());
Assert.assertEquals(alluxio.thrift.TTtlAction.Free, thriftOptions.getTtlAction());
Assert.assertEquals(mode.toShort(), thriftOptions.getMode());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CreateFileOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
Random random = new Random();
long blockSize = random.nextLong();
FileWriteLocationPolicy policy = new RoundRobinPolicy();
Mode mode = new Mode((short) random.nextInt());
boolean recursive = random.nextBoolean();
long ttl = random.nextLong();
int writeTier = random.nextInt();
WriteType writeType = WriteType.NONE;
CreateFileOptions options = CreateFileOptions.defaults();
options.setBlockSizeBytes(blockSize);
options.setLocationPolicy(policy);
options.setMode(mode);
options.setRecursive(recursive);
options.setTtl(ttl);
options.setTtlAction(TtlAction.FREE);
options.setWriteTier(writeTier);
options.setWriteType(writeType);
Assert.assertEquals(blockSize, options.getBlockSizeBytes());
Assert.assertEquals(policy, options.getLocationPolicy());
Assert.assertEquals(mode, options.getMode());
Assert.assertEquals(recursive, options.isRecursive());
Assert.assertEquals(ttl, options.getTtl());
Assert.assertEquals(TtlAction.FREE, options.getTtlAction());
Assert.assertEquals(writeTier, options.getWriteTier());
Assert.assertEquals(writeType, options.getWriteType());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CreateUfsFileOptionsTest method toThrift.
/**
* Tests conversion to thrift representation.
*/
@Test
public void toThrift() throws IOException {
Random random = new Random();
String owner = CommonUtils.randomAlphaNumString(10);
String group = CommonUtils.randomAlphaNumString(10);
Mode mode = new Mode((short) random.nextInt());
CreateUfsFileOptions options = CreateUfsFileOptions.defaults();
options.setOwner(owner);
options.setGroup(group);
options.setMode(mode);
CreateUfsFileTOptions thriftOptions = options.toThrift();
Assert.assertEquals(owner, thriftOptions.getOwner());
Assert.assertEquals(group, thriftOptions.getGroup());
Assert.assertEquals(mode.toShort(), thriftOptions.getMode());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class AbstractFileSystem method mkdirs.
/**
* Attempts to create a folder with the specified path. Parent directories will be created.
*
* @param path path to create
* @param permission permissions to grant the created folder
* @return true if the indicated folder is created successfully or already exists
*/
@Override
public boolean mkdirs(Path path, FsPermission permission) throws IOException {
LOG.debug("mkdirs({}, {})", path, permission);
if (mStatistics != null) {
mStatistics.incrementWriteOps(1);
}
AlluxioURI uri = getAlluxioPath(path);
CreateDirectoryPOptions options = CreateDirectoryPOptions.newBuilder().setRecursive(true).setAllowExists(true).setMode(new Mode(permission.toShort()).toProto()).build();
try {
mFileSystem.createDirectory(uri, options);
return true;
} catch (AlluxioException e) {
throw new IOException(e);
}
}
Aggregations