Search in sources :

Example 1 with CreateFileTOptions

use of alluxio.thrift.CreateFileTOptions 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 2 with CreateFileTOptions

use of alluxio.thrift.CreateFileTOptions in project alluxio by Alluxio.

the class CreateFileOptions method toThrift.

/**
   * @return Thrift representation of the options
   */
public CreateFileTOptions toThrift() {
    CreateFileTOptions options = new CreateFileTOptions();
    options.setBlockSizeBytes(mBlockSizeBytes);
    options.setPersisted(mWriteType.isThrough());
    options.setRecursive(mRecursive);
    options.setTtl(mTtl);
    options.setTtlAction(ThriftUtils.toThrift(mTtlAction));
    if (mMode != null) {
        options.setMode(mMode.toShort());
    }
    return options;
}
Also used : CreateFileTOptions(alluxio.thrift.CreateFileTOptions)

Aggregations

CreateFileTOptions (alluxio.thrift.CreateFileTOptions)2 WriteType (alluxio.client.WriteType)1 FileWriteLocationPolicy (alluxio.client.file.policy.FileWriteLocationPolicy)1 RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)1 Mode (alluxio.security.authorization.Mode)1 Random (java.util.Random)1 Test (org.junit.Test)1