Search in sources :

Example 1 with CompleteFilePOptions

use of alluxio.grpc.CompleteFilePOptions in project alluxio by Alluxio.

the class FileOutStreamTest method asyncWrite.

/**
 * Tests that the async write invokes the expected client APIs.
 */
@Test
public void asyncWrite() throws Exception {
    OutStreamOptions options = OutStreamOptions.defaults(mClientContext).setBlockSizeBytes(BLOCK_LENGTH).setWriteType(WriteType.ASYNC_THROUGH);
    mTestStream = createTestStream(FILE_NAME, options);
    mTestStream.write(BufferUtils.getIncreasingByteArray((int) (BLOCK_LENGTH * 1.5)));
    mTestStream.close();
    // Verify that async persist request is sent with complete file request.
    ArgumentCaptor<CompleteFilePOptions> parameterCaptor = ArgumentCaptor.forClass(CompleteFilePOptions.class);
    verify(mFileSystemMasterClient).completeFile(eq(FILE_NAME), parameterCaptor.capture());
    Assert.assertTrue(parameterCaptor.getValue().hasAsyncPersistOptions());
}
Also used : OutStreamOptions(alluxio.client.file.options.OutStreamOptions) CompleteFilePOptions(alluxio.grpc.CompleteFilePOptions) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with CompleteFilePOptions

use of alluxio.grpc.CompleteFilePOptions in project alluxio by Alluxio.

the class FileOutStreamTest method asyncWriteOptionPropagation.

/**
 * Tests that common options are propagated to async write request.
 */
@Test
public void asyncWriteOptionPropagation() throws Exception {
    Random rand = new Random();
    FileSystemMasterCommonPOptions commonOptions = FileSystemMasterCommonPOptions.newBuilder().setTtl(rand.nextLong()).setTtlAction(TtlAction.values()[rand.nextInt(TtlAction.values().length)]).setSyncIntervalMs(rand.nextLong()).build();
    OutStreamOptions options = new OutStreamOptions(CreateFilePOptions.newBuilder().setWriteType(WritePType.ASYNC_THROUGH).setBlockSizeBytes(BLOCK_LENGTH).setCommonOptions(commonOptions).build(), mClientContext, sConf);
    // Verify that OutStreamOptions have captured the common options properly.
    assertEquals(options.getCommonOptions(), commonOptions);
    mTestStream = createTestStream(FILE_NAME, options);
    mTestStream.write(BufferUtils.getIncreasingByteArray((int) (BLOCK_LENGTH * 1.5)));
    mTestStream.close();
    verify(mFileSystemMasterClient).completeFile(eq(FILE_NAME), any(CompleteFilePOptions.class));
    // Verify that common options for OutStreamOptions are propagated to ScheduleAsyncPersistence.
    ArgumentCaptor<CompleteFilePOptions> parameterCaptor = ArgumentCaptor.forClass(CompleteFilePOptions.class);
    verify(mFileSystemMasterClient).completeFile(eq(FILE_NAME), parameterCaptor.capture());
    assertEquals(parameterCaptor.getValue().getAsyncPersistOptions().getCommonOptions(), options.getCommonOptions());
}
Also used : OutStreamOptions(alluxio.client.file.options.OutStreamOptions) Random(java.util.Random) FileSystemMasterCommonPOptions(alluxio.grpc.FileSystemMasterCommonPOptions) CompleteFilePOptions(alluxio.grpc.CompleteFilePOptions) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with CompleteFilePOptions

use of alluxio.grpc.CompleteFilePOptions in project alluxio by Alluxio.

the class FileSystemMasterOptionsTest method completeFileDefaultsTest.

@Test
public void completeFileDefaultsTest() {
    CompleteFilePOptions options = FileSystemMasterOptions.completeFileDefaults();
    Assert.assertNotNull(options);
    Assert.assertEquals(0, options.getUfsLength());
}
Also used : CompleteFilePOptions(alluxio.grpc.CompleteFilePOptions) Test(org.junit.Test)

Example 4 with CompleteFilePOptions

use of alluxio.grpc.CompleteFilePOptions in project alluxio by Alluxio.

the class CompleteFileContext method mergeFrom.

/**
 * Merges and embeds the given {@link CompleteFilePOptions} with the corresponding master options.
 *
 * @param optionsBuilder Builder for proto {@link CompleteFilePOptions} to merge with defaults
 * @return the instance of {@link CompleteFileContext} with default values for master
 */
public static CompleteFileContext mergeFrom(CompleteFilePOptions.Builder optionsBuilder) {
    CompleteFilePOptions masterOptions = FileSystemMasterOptions.completeFileDefaults();
    CompleteFilePOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
    return create(mergedOptionsBuilder);
}
Also used : CompleteFilePOptions(alluxio.grpc.CompleteFilePOptions)

Aggregations

CompleteFilePOptions (alluxio.grpc.CompleteFilePOptions)4 Test (org.junit.Test)3 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileSystemMasterCommonPOptions (alluxio.grpc.FileSystemMasterCommonPOptions)1 Random (java.util.Random)1