Search in sources :

Example 1 with WriteType

use of alluxio.client.WriteType in project alluxio by Alluxio.

the class CreateDirectoryOptionsTest method fields.

/**
   * Tests getting and setting fields.
   */
@Test
public void fields() {
    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);
    Assert.assertEquals(allowExists, options.isAllowExists());
    Assert.assertEquals(mode, options.getMode());
    Assert.assertEquals(recursive, options.isRecursive());
    Assert.assertEquals(ttl, options.getTtl());
    Assert.assertEquals(TtlAction.FREE, options.getTtlAction());
    Assert.assertEquals(writeType, options.getWriteType());
}
Also used : Random(java.util.Random) WriteType(alluxio.client.WriteType) Mode(alluxio.security.authorization.Mode) Test(org.junit.Test)

Example 2 with WriteType

use of alluxio.client.WriteType 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 WriteType

use of alluxio.client.WriteType in project alluxio by Alluxio.

the class FileOutStreamTest method getBytesWrittenWithDifferentUnderStorageType.

/**
   * Tests that the number of bytes written is correct when the stream is created with different
   * under storage types.
   */
@Test
public void getBytesWrittenWithDifferentUnderStorageType() throws IOException {
    for (WriteType type : WriteType.values()) {
        OutStreamOptions options = OutStreamOptions.defaults().setBlockSizeBytes(BLOCK_LENGTH).setWriteType(type).setUfsPath(FILE_NAME.getPath());
        mTestStream = createTestStream(FILE_NAME, options);
        mTestStream.write(BufferUtils.getIncreasingByteArray((int) BLOCK_LENGTH));
        mTestStream.flush();
        Assert.assertEquals(BLOCK_LENGTH, mTestStream.getBytesWritten());
    }
}
Also used : OutStreamOptions(alluxio.client.file.options.OutStreamOptions) WriteType(alluxio.client.WriteType) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with WriteType

use of alluxio.client.WriteType 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)

Example 5 with WriteType

use of alluxio.client.WriteType 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)

Aggregations

WriteType (alluxio.client.WriteType)7 Test (org.junit.Test)6 Mode (alluxio.security.authorization.Mode)5 Random (java.util.Random)5 FileWriteLocationPolicy (alluxio.client.file.policy.FileWriteLocationPolicy)3 RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)3 ReadType (alluxio.client.ReadType)1 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)1 CreateDirectoryTOptions (alluxio.thrift.CreateDirectoryTOptions)1 CreateFileTOptions (alluxio.thrift.CreateFileTOptions)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1