use of alluxio.client.WriteType in project alluxio by Alluxio.
the class CreateDirectoryOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
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);
Assert.assertEquals(allowExists, options.isAllowExists());
Assert.assertEquals(mode, options.getMode());
Assert.assertEquals(recursive, options.isRecursive());
Assert.assertEquals(ttl, options.getTtl());
Assert.assertEquals(TtlAction.FREE, options.getTtlAction());
Assert.assertEquals(writeType, options.getWriteType());
}
use of alluxio.client.WriteType in project alluxio by Alluxio.
the class CreateFileOptionsTest method toThrift.
/**
* Tests conversion to thrift representation.
*/
@Test
public void toThrift() {
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);
CreateFileTOptions thriftOptions = options.toThrift();
Assert.assertEquals(blockSize, thriftOptions.getBlockSizeBytes());
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.client.WriteType in project alluxio by Alluxio.
the class FileOutStreamTest method getBytesWrittenWithDifferentUnderStorageType.
/**
* Tests that the number of bytes written is correct when the stream is created with different
* under storage types.
*/
@Test
public void getBytesWrittenWithDifferentUnderStorageType() throws IOException {
for (WriteType type : WriteType.values()) {
OutStreamOptions options = OutStreamOptions.defaults().setBlockSizeBytes(BLOCK_LENGTH).setWriteType(type).setUfsPath(FILE_NAME.getPath());
mTestStream = createTestStream(FILE_NAME, options);
mTestStream.write(BufferUtils.getIncreasingByteArray((int) BLOCK_LENGTH));
mTestStream.flush();
Assert.assertEquals(BLOCK_LENGTH, mTestStream.getBytesWritten());
}
}
use of alluxio.client.WriteType 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.client.WriteType 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());
}
Aggregations