Search in sources :

Example 1 with FileWriteLocationPolicy

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());
}
Also used : FileWriteLocationPolicy(alluxio.client.file.policy.FileWriteLocationPolicy) ReadType(alluxio.client.ReadType) RoundRobinPolicy(alluxio.client.file.policy.RoundRobinPolicy) Test(org.junit.Test)

Example 2 with FileWriteLocationPolicy

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());
}
Also used : FileWriteLocationPolicy(alluxio.client.file.policy.FileWriteLocationPolicy) CreateFileTOptions(alluxio.thrift.CreateFileTOptions) Random(java.util.Random) WriteType(alluxio.client.WriteType) Mode(alluxio.security.authorization.Mode) RoundRobinPolicy(alluxio.client.file.policy.RoundRobinPolicy) Test(org.junit.Test)

Example 3 with FileWriteLocationPolicy

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());
}
Also used : FileWriteLocationPolicy(alluxio.client.file.policy.FileWriteLocationPolicy) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with FileWriteLocationPolicy

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());
}
Also used : FileWriteLocationPolicy(alluxio.client.file.policy.FileWriteLocationPolicy) Random(java.util.Random) WriteType(alluxio.client.WriteType) Mode(alluxio.security.authorization.Mode) RoundRobinPolicy(alluxio.client.file.policy.RoundRobinPolicy) Test(org.junit.Test)

Example 5 with FileWriteLocationPolicy

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());
}
Also used : FileWriteLocationPolicy(alluxio.client.file.policy.FileWriteLocationPolicy) DeterministicHashPolicy(alluxio.client.block.policy.DeterministicHashPolicy) ReadType(alluxio.client.ReadType) RoundRobinPolicy(alluxio.client.file.policy.RoundRobinPolicy) BlockLocationPolicy(alluxio.client.block.policy.BlockLocationPolicy) Test(org.junit.Test)

Aggregations

FileWriteLocationPolicy (alluxio.client.file.policy.FileWriteLocationPolicy)5 Test (org.junit.Test)5 RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)4 ReadType (alluxio.client.ReadType)2 WriteType (alluxio.client.WriteType)2 Mode (alluxio.security.authorization.Mode)2 Random (java.util.Random)2 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)1 BlockLocationPolicy (alluxio.client.block.policy.BlockLocationPolicy)1 DeterministicHashPolicy (alluxio.client.block.policy.DeterministicHashPolicy)1 CreateFileTOptions (alluxio.thrift.CreateFileTOptions)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1