Search in sources :

Example 1 with CreateDirectoryOptions

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

the class BaseFileSystemTest method createDirectory.

/**
   * Tests for the {@link BaseFileSystem#createDirectory(AlluxioURI, CreateDirectoryOptions)}
   * method.
   */
@Test
public void createDirectory() throws Exception {
    AlluxioURI dir = new AlluxioURI("/dir");
    CreateDirectoryOptions createDirectoryOptions = CreateDirectoryOptions.defaults();
    Mockito.doNothing().when(mFileSystemMasterClient).createDirectory(dir, createDirectoryOptions);
    mFileSystem.createDirectory(dir, createDirectoryOptions);
    Mockito.verify(mFileSystemMasterClient).createDirectory(dir, createDirectoryOptions);
}
Also used : CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with CreateDirectoryOptions

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

the class BaseFileSystemTest method createDirectoryException.

/**
   * Ensures that an exception is propagated correctly when creating a directory.
   */
@Test
public void createDirectoryException() throws Exception {
    AlluxioURI dir = new AlluxioURI("/dir");
    CreateDirectoryOptions createDirectoryOptions = CreateDirectoryOptions.defaults();
    Mockito.doThrow(EXCEPTION).when(mFileSystemMasterClient).createDirectory(dir, createDirectoryOptions);
    try {
        mFileSystem.createDirectory(dir, createDirectoryOptions);
        Assert.fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
    } catch (Exception e) {
        Assert.assertSame(EXCEPTION, e);
    }
}
Also used : CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with CreateDirectoryOptions

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

the class CheckConsistencyIntegrationTest method before.

@Before
public final void before() throws Exception {
    mFileSystemMaster = mLocalAlluxioClusterResource.get().getMaster().getInternalMaster().getFileSystemMaster();
    AuthenticatedClientUser.set(TEST_USER);
    mFileSystem = FileSystem.Factory.get();
    CreateDirectoryOptions dirOptions = CreateDirectoryOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
    CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
    mFileSystem.createDirectory(DIRECTORY, dirOptions);
    mFileSystem.createFile(FILE, fileOptions).close();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) Before(org.junit.Before)

Example 4 with CreateDirectoryOptions

use of alluxio.client.file.options.CreateDirectoryOptions 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 CreateDirectoryOptions

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

the class JournalIntegrationTest method persistDirectoryLater.

@Test
public void persistDirectoryLater() throws Exception {
    String[] directories = new String[] { "/d11", "/d11/d21", "/d11/d22", "/d12", "/d12/d21", "/d12/d22" };
    CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true).setWriteType(WriteType.MUST_CACHE);
    for (String directory : directories) {
        mFileSystem.createDirectory(new AlluxioURI(directory), options);
    }
    options.setWriteType(WriteType.CACHE_THROUGH);
    for (String directory : directories) {
        mFileSystem.createDirectory(new AlluxioURI(directory), options);
    }
    Map<String, URIStatus> directoryStatuses = new HashMap<>();
    for (String directory : directories) {
        directoryStatuses.put(directory, mFileSystem.getStatus(new AlluxioURI(directory)));
    }
    mLocalAlluxioCluster.stopFS();
    persistDirectoryLaterTestUtil(directoryStatuses);
    deleteFsMasterJournalLogs();
    persistDirectoryLaterTestUtil(directoryStatuses);
}
Also used : HashMap(java.util.HashMap) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) Matchers.anyString(org.mockito.Matchers.anyString) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

CreateDirectoryOptions (alluxio.client.file.options.CreateDirectoryOptions)10 AlluxioURI (alluxio.AlluxioURI)8 Test (org.junit.Test)6 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)4 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 URIStatus (alluxio.client.file.URIStatus)1 DeleteOptions (alluxio.client.file.options.DeleteOptions)1 AlluxioException (alluxio.exception.AlluxioException)1 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 Mode (alluxio.security.authorization.Mode)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1