Search in sources :

Example 1 with CreateDirectoryTOptions

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

the class CreateDirectoryOptions method toThrift.

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

Example 2 with CreateDirectoryTOptions

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

the class CreateDirectoryOptionsTest method toThrift.

/**
   * Tests conversion to thrift representation.
   */
@Test
public void toThrift() {
    Random random = new Random();
    boolean allowExists = random.nextBoolean();
    boolean recursive = random.nextBoolean();
    Mode mode = new Mode((short) random.nextInt());
    long ttl = random.nextLong();
    WriteType writeType = WriteType.NONE;
    CreateDirectoryOptions options = CreateDirectoryOptions.defaults();
    options.setAllowExists(allowExists);
    options.setMode(mode);
    options.setTtl(ttl);
    options.setTtlAction(TtlAction.FREE);
    options.setRecursive(recursive);
    options.setWriteType(writeType);
    CreateDirectoryTOptions thriftOptions = options.toThrift();
    Assert.assertEquals(allowExists, thriftOptions.isAllowExists());
    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 : Random(java.util.Random) WriteType(alluxio.client.WriteType) Mode(alluxio.security.authorization.Mode) CreateDirectoryTOptions(alluxio.thrift.CreateDirectoryTOptions) Test(org.junit.Test)

Aggregations

CreateDirectoryTOptions (alluxio.thrift.CreateDirectoryTOptions)2 WriteType (alluxio.client.WriteType)1 Mode (alluxio.security.authorization.Mode)1 Random (java.util.Random)1 Test (org.junit.Test)1