use of alluxio.client.file.policy.FileWriteLocationPolicy 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.FileWriteLocationPolicy 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.FileWriteLocationPolicy in project alluxio by Alluxio.
the class FileInStreamTest method locationPolicy.
/**
* Tests that the file in stream uses the supplied location policy.
*/
@Test
public void locationPolicy() throws Exception {
FileWriteLocationPolicy policy = Mockito.mock(FileWriteLocationPolicy.class);
mTestStream = new FileInStream(mStatus, InStreamOptions.defaults().setReadType(ReadType.CACHE).setLocationPolicy(policy), mContext);
mTestStream.read();
Mockito.verify(policy).getWorkerForNextBlock(Mockito.anyListOf(BlockWorkerInfo.class), Mockito.anyLong());
}
use of alluxio.client.file.policy.FileWriteLocationPolicy 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.FileWriteLocationPolicy 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