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);
}
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();
}
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();
}
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;
}
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;
}
Aggregations