Search in sources :

Example 1 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class LineageFileSystemTest method getDummyOutStream.

/**
   * Tests that a {@link DummyFileOutputStream} is returned.
   */
@Test
public void getDummyOutStream() throws Exception {
    AlluxioURI path = new AlluxioURI("test");
    Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.DELETE)).thenReturn(-1L);
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0);
    FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
    Assert.assertTrue(outStream instanceof DummyFileOutputStream);
    // verify client is released
    Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class LineageFileSystemTest method getLineageOutStream.

/**
   * Tests that a {@link LineageFileOutStream} is returned.
   */
@Test
public void getLineageOutStream() throws Exception {
    AlluxioURI path = new AlluxioURI("test");
    Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.FREE)).thenReturn(1L);
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0).setTtlAction(alluxio.wire.TtlAction.FREE);
    FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
    Assert.assertTrue(outStream instanceof LineageFileOutStream);
    // verify client is released
    Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class PinIntegrationTest method createEmptyFile.

private void createEmptyFile(AlluxioURI fileURI) throws IOException, AlluxioException {
    CreateFileOptions options = CreateFileOptions.defaults().setWriteType(WriteType.MUST_CACHE);
    FileOutStream os = mFileSystem.createFile(fileURI, options);
    os.close();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream)

Example 4 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class StartupConsistencyCheckTest method before.

@Before
public void before() throws Exception {
    CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.THROUGH);
    CreateDirectoryOptions dirOptions = CreateDirectoryOptions.defaults().setWriteType(WriteType.THROUGH);
    mCluster = mLocalAlluxioClusterResource.get();
    mFileSystem = mCluster.getClient();
    mFileSystem.createFile(TOP_LEVEL_FILE, fileOptions).close();
    mFileSystem.createDirectory(TOP_LEVEL_DIR, dirOptions);
    mFileSystem.createDirectory(SECOND_LEVEL_DIR, dirOptions);
    mFileSystem.createFile(SECOND_LEVEL_FILE, fileOptions).close();
    mFileSystem.createFile(THIRD_LEVEL_FILE, fileOptions).close();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) Before(org.junit.Before)

Example 5 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class JournalIntegrationTest method rename.

/**
   * Tests file and directory creation, and rename.
   */
@Test
public void rename() throws Exception {
    for (int i = 0; i < 10; i++) {
        mFileSystem.createDirectory(new AlluxioURI("/i" + i));
        for (int j = 0; j < 10; j++) {
            CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes((i + j + 1) * 64);
            AlluxioURI path = new AlluxioURI("/i" + i + "/j" + j);
            mFileSystem.createFile(path, option).close();
            mFileSystem.rename(path, new AlluxioURI("/i" + i + "/jj" + j));
        }
        mFileSystem.rename(new AlluxioURI("/i" + i), new AlluxioURI("/ii" + i));
    }
    mLocalAlluxioCluster.stopFS();
    renameTestUtil();
    deleteFsMasterJournalLogs();
    renameTestUtil();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

CreateFileOptions (alluxio.client.file.options.CreateFileOptions)57 AlluxioURI (alluxio.AlluxioURI)51 Test (org.junit.Test)45 FileInStream (alluxio.client.file.FileInStream)21 FileOutStream (alluxio.client.file.FileOutStream)16 URIStatus (alluxio.client.file.URIStatus)11 HashMap (java.util.HashMap)5 CreateDirectoryOptions (alluxio.client.file.options.CreateDirectoryOptions)4 BeforeClass (org.junit.BeforeClass)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 AlluxioException (alluxio.exception.AlluxioException)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2 IOException (java.io.IOException)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 DeleteOptions (alluxio.client.file.options.DeleteOptions)1 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)1 SetAttributeOptions (alluxio.client.file.options.SetAttributeOptions)1 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1