use of alluxio.client.file.policy.RoundRobinPolicy in project alluxio by Alluxio.
the class OpenFileOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
FileWriteLocationPolicy policy = new RoundRobinPolicy();
ReadType readType = ReadType.NO_CACHE;
OpenFileOptions options = OpenFileOptions.defaults();
options.setReadType(readType);
options.setCacheLocationPolicy(policy);
options.setMaxUfsReadConcurrency(5);
options.setUfsReadLocationPolicy((BlockLocationPolicy) policy);
Assert.assertEquals(readType, options.getReadType());
Assert.assertEquals(policy, options.getCacheLocationPolicy());
Assert.assertEquals(5, options.getMaxUfsReadConcurrency());
Assert.assertEquals(policy, options.getUfsReadLocationPolicy());
}
use of alluxio.client.file.policy.RoundRobinPolicy 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.file.policy.RoundRobinPolicy in project alluxio by Alluxio.
the class MultiWorkerIntegrationTest method writeLargeFile.
@Test
public void writeLargeFile() throws Exception {
int fileSize = NUM_WORKERS * WORKER_MEMORY_SIZE_BYTES;
AlluxioURI file = new AlluxioURI("/test");
FileSystem fs = mResource.get().getClient();
// Write a file large enough to fill all the memory of all the workers.
FileSystemTestUtils.createByteFile(fs, file.getPath(), fileSize, CreateFileOptions.defaults().setWriteType(WriteType.MUST_CACHE).setLocationPolicy(new RoundRobinPolicy()));
URIStatus status = fs.getStatus(file);
assertEquals(100, status.getInMemoryPercentage());
try (FileInStream inStream = fs.openFile(file)) {
assertEquals(fileSize, IOUtils.toByteArray(inStream).length);
}
}
use of alluxio.client.file.policy.RoundRobinPolicy 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.client.file.policy.RoundRobinPolicy in project alluxio by Alluxio.
the class InStreamOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
ReadType readType = ReadType.NO_CACHE;
FileWriteLocationPolicy policy = new RoundRobinPolicy();
BlockLocationPolicy blockLocationPolicy = new DeterministicHashPolicy();
InStreamOptions options = InStreamOptions.defaults();
options.setReadType(readType);
options.setLocationPolicy(policy);
options.setCachePartiallyReadBlock(true);
options.setSeekBufferSizeBytes(Constants.MB);
options.setUfsReadLocationPolicy(blockLocationPolicy);
options.setMaxUfsReadConcurrency(5);
Assert.assertEquals(options.getAlluxioStorageType(), readType.getAlluxioStorageType());
Assert.assertEquals(policy, options.getCacheLocationPolicy());
Assert.assertTrue(options.isCachePartiallyReadBlock());
Assert.assertEquals(Constants.MB, options.getSeekBufferSizeBytes());
Assert.assertEquals(blockLocationPolicy, options.getUfsReadLocationPolicy());
Assert.assertEquals(5, options.getMaxUfsReadConcurrency());
}
Aggregations