Search in sources :

Example 1 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class FileSystemMasterClientServiceHandler method createDirectory.

@Override
public void createDirectory(CreateDirectoryPRequest request, StreamObserver<CreateDirectoryPResponse> responseObserver) {
    CreateDirectoryPOptions options = request.getOptions();
    RpcUtils.call(LOG, () -> {
        AlluxioURI pathUri = getAlluxioURI(request.getPath());
        mFileSystemMaster.createDirectory(pathUri, CreateDirectoryContext.create(options.toBuilder()).withTracker(new GrpcCallTracker(responseObserver)));
        return CreateDirectoryPResponse.newBuilder().build();
    }, "CreateDirectory", "request=%s", responseObserver, request);
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) GrpcCallTracker(alluxio.master.file.contexts.GrpcCallTracker) AlluxioURI(alluxio.AlluxioURI)

Example 2 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method createDirectory.

// /**
// * Tests for the {@link BaseFileSystem#loadMetadata(AlluxioURI, LoadMetadataOptions)}
// * method.
// */
// @Test
// public void loadMetadata() throws Exception {
// AlluxioURI file = new AlluxioURI("/file");
// LoadMetadataOptions loadMetadataOptions = LoadMetadataOptions.defaults().setRecursive(true);
// doNothing().when(mFileSystemMasterClient).loadMetadata(file, loadMetadataOptions);
// mFileSystem.loadMetadata(file, loadMetadataOptions);
// verify(mFileSystemMasterClient).loadMetadata(file, loadMetadataOptions);
// 
// verifyFilesystemContextAcquiredAndReleased();
// }
// 
// /**
// * Ensures that an exception is propagated correctly when loading the metadata.
// */
// @Test
// public void loadMetadataException() throws Exception {
// AlluxioURI file = new AlluxioURI("/file");
// LoadMetadataOptions loadMetadataOptions = LoadMetadataOptions.defaults().setRecursive(true);
// doThrow(EXCEPTION).when(mFileSystemMasterClient)
// .loadMetadata(file, loadMetadataOptions);
// try {
// mFileSystem.loadMetadata(file, loadMetadataOptions);
// fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
// } catch (Exception e) {
// assertSame(EXCEPTION, e);
// }
// 
// verifyFilesystemContextAcquiredAndReleased();
// }
/**
 * Tests for the {@link BaseFileSystem#createDirectory(AlluxioURI, CreateDirectoryPOptions)}
 * method.
 */
@Test
public void createDirectory() throws Exception {
    AlluxioURI dir = new AlluxioURI("/dir");
    CreateDirectoryPOptions createDirectoryOptions = CreateDirectoryPOptions.getDefaultInstance();
    doNothing().when(mFileSystemMasterClient).createDirectory(dir, FileSystemOptions.createDirectoryDefaults(mConf).toBuilder().mergeFrom(createDirectoryOptions).build());
    mFileSystem.createDirectory(dir, createDirectoryOptions);
    verify(mFileSystemMasterClient).createDirectory(dir, FileSystemOptions.createDirectoryDefaults(mConf).toBuilder().mergeFrom(createDirectoryOptions).build());
    verifyFilesystemContextAcquiredAndReleased();
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions 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");
    CreateDirectoryPOptions createDirectoryOptions = CreateDirectoryPOptions.getDefaultInstance();
    doThrow(EXCEPTION).when(mFileSystemMasterClient).createDirectory(dir, FileSystemOptions.createDirectoryDefaults(mConf).toBuilder().mergeFrom(createDirectoryOptions).build());
    try {
        mFileSystem.createDirectory(dir, createDirectoryOptions);
        fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
    } catch (Exception e) {
        assertSame(EXCEPTION, e);
    }
    verifyFilesystemContextAcquiredAndReleased();
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class MkdirCommand method run.

@Override
public int run(CommandLine cl) throws AlluxioException, IOException {
    String[] args = cl.getArgs();
    for (String path : args) {
        AlluxioURI inputPath = new AlluxioURI(path);
        CreateDirectoryPOptions options = CreateDirectoryPOptions.newBuilder().setRecursive(true).build();
        mFileSystem.createDirectory(inputPath, options);
        System.out.println("Successfully created directory " + inputPath);
    }
    return 0;
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) AlluxioURI(alluxio.AlluxioURI)

Example 5 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class FileSystemShellUtilsTest method resetFileHierarchy.

/**
 * Resets the file hierarchy.
 *
 * @param fs the file system
 * @param writeType write types for creating a file in Alluxio
 * @return the test directory
 */
public static String resetFileHierarchy(FileSystem fs, WritePType writeType) throws IOException, AlluxioException {
    /**
     * Generate such local structure TEST_DIR
     *                                ├── foo |
     *                                        ├── foobar1
     *                                        └── foobar2
     *                                ├── bar |
     *                                        └── foobar3
     *                                └── foobar4
     */
    if (fs.exists(new AlluxioURI(TEST_DIR))) {
        fs.delete(new AlluxioURI(TEST_DIR), DeletePOptions.newBuilder().setRecursive(true).build());
    }
    CreateDirectoryPOptions dirOptions = CreateDirectoryPOptions.getDefaultInstance().toBuilder().setWriteType(writeType).build();
    fs.createDirectory(new AlluxioURI(TEST_DIR), dirOptions);
    fs.createDirectory(new AlluxioURI(TEST_DIR + "/foo"), dirOptions);
    fs.createDirectory(new AlluxioURI(TEST_DIR + "/bar"), dirOptions);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foo/foobar1", writeType, 10);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foo/foobar2", writeType, 20);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/bar/foobar3", writeType, 30);
    FileSystemTestUtils.createByteFile(fs, TEST_DIR + "/foobar4", writeType, 40);
    return TEST_DIR;
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) AlluxioURI(alluxio.AlluxioURI)

Aggregations

CreateDirectoryPOptions (alluxio.grpc.CreateDirectoryPOptions)15 AlluxioURI (alluxio.AlluxioURI)12 Test (org.junit.Test)5 AlluxioException (alluxio.exception.AlluxioException)4 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)4 IOException (java.io.IOException)4 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)3 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)3 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)3 FileSystem (alluxio.client.file.FileSystem)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileInStream (alluxio.client.file.FileInStream)1 FileOutStream (alluxio.client.file.FileOutStream)1 URIStatus (alluxio.client.file.URIStatus)1 DeletePOptions (alluxio.grpc.DeletePOptions)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 GrpcCallTracker (alluxio.master.file.contexts.GrpcCallTracker)1