Search in sources :

Example 1 with RoundRobinPolicy

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());
}
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 RoundRobinPolicy

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());
}
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 RoundRobinPolicy

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

Example 4 with RoundRobinPolicy

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());
}
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 RoundRobinPolicy

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());
}
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

RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)6 Test (org.junit.Test)6 FileWriteLocationPolicy (alluxio.client.file.policy.FileWriteLocationPolicy)5 WriteType (alluxio.client.WriteType)3 Mode (alluxio.security.authorization.Mode)3 Random (java.util.Random)3 ReadType (alluxio.client.ReadType)2 AlluxioURI (alluxio.AlluxioURI)1 BlockLocationPolicy (alluxio.client.block.policy.BlockLocationPolicy)1 DeterministicHashPolicy (alluxio.client.block.policy.DeterministicHashPolicy)1 FileInStream (alluxio.client.file.FileInStream)1 FileSystem (alluxio.client.file.FileSystem)1 URIStatus (alluxio.client.file.URIStatus)1 CreateFileTOptions (alluxio.thrift.CreateFileTOptions)1