Search in sources :

Example 66 with CreateFilePOptions

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);
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions)

Example 67 with CreateFilePOptions

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);
}
Also used : Runtime(jnr.ffi.Runtime) FileOutStream(alluxio.client.file.FileOutStream) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) Pointer(jnr.ffi.Pointer) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 68 with CreateFilePOptions

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();
}
Also used : FileOutStream(alluxio.client.file.FileOutStream) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

CreateFilePOptions (alluxio.grpc.CreateFilePOptions)68 AlluxioURI (alluxio.AlluxioURI)61 Test (org.junit.Test)49 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)36 FileInStream (alluxio.client.file.FileInStream)27 FileOutStream (alluxio.client.file.FileOutStream)16 URIStatus (alluxio.client.file.URIStatus)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 FileSystem (alluxio.client.file.FileSystem)4 AlluxioException (alluxio.exception.AlluxioException)4 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)4 CreateDirectoryPOptions (alluxio.grpc.CreateDirectoryPOptions)4 IOException (java.io.IOException)4 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)3 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 ArrayList (java.util.ArrayList)3 ConfigurationRule (alluxio.ConfigurationRule)2 BlockMaster (alluxio.master.block.BlockMaster)2 Mode (alluxio.security.authorization.Mode)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2