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