use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class CreateFileContext method mergeFrom.
/**
* Merges and embeds the given {@link CreateFilePOptions} with the corresponding master options.
*
* @param optionsBuilder Builder for proto {@link CreateFilePOptions} to embed
* @return the instance of {@link CreateFileContext} with default values for master
*/
public static CreateFileContext mergeFrom(CreateFilePOptions.Builder optionsBuilder) {
CreateFilePOptions masterOptions = FileSystemOptions.createFileDefaults(ServerConfiguration.global());
CreateFilePOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
return new CreateFileContext(mergedOptionsBuilder);
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class AlluxioFuseFileSystemTest method write.
@Test
public void write() throws Exception {
FileOutStream fos = mock(FileOutStream.class);
AlluxioURI anyURI = any();
CreateFilePOptions options = any();
when(mFileSystem.createFile(anyURI, options)).thenReturn(fos);
// open a file
mFileInfo.flags.set(O_WRONLY.intValue());
mFuseFs.create("/foo/bar", 0, mFileInfo);
// prepare something to write into it
Runtime r = Runtime.getSystemRuntime();
Pointer ptr = r.getMemoryManager().allocateTemporary(4, true);
byte[] expected = { 42, -128, 1, 3 };
ptr.put(0, expected, 0, 4);
mFuseFs.write("/foo/bar", ptr, 4, 0, mFileInfo);
verify(fos).write(expected);
// the second write is no-op because the writes must be sequential and overwriting is supported
mFuseFs.write("/foo/bar", ptr, 4, 0, mFileInfo);
verify(fos, times(1)).write(expected);
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class AlluxioJniFuseFileSystemTest method flush.
@Test
public void flush() throws Exception {
FileOutStream fos = mock(FileOutStream.class);
AlluxioURI anyURI = any();
CreateFilePOptions options = any();
when(mFileSystem.createFile(anyURI, options)).thenReturn(fos);
// open a file
mFileInfo.flags.set(O_WRONLY.intValue());
mFuseFs.create("/foo/bar", 0, mFileInfo);
// then call flush into it
mFuseFs.flush("/foo/bar", mFileInfo);
verify(fos).flush();
}
Aggregations