use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method largeTree.
/**
* Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyContext)} method
* when some files are consistent in a larger inode tree.
*/
@Test
public void largeTree() throws Exception {
CreateDirectoryPOptions dirOptions = CreateDirectoryPOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
CreateFilePOptions fileOptions = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
AlluxioURI nestedDir = DIRECTORY.join("/dir2");
AlluxioURI topLevelFile = new AlluxioURI("/file");
AlluxioURI thirdLevelFile = nestedDir.join("/file");
mFileSystem.createDirectory(nestedDir, dirOptions);
mFileSystem.createFile(topLevelFile, fileOptions).close();
mFileSystem.createFile(thirdLevelFile, fileOptions).close();
String ufsDirectory = mFileSystem.getStatus(nestedDir).getUfsPath();
UnderFileSystem ufs = UnderFileSystem.Factory.create(ufsDirectory, ServerConfiguration.global());
ufs.deleteDirectory(ufsDirectory, DeleteOptions.defaults().setRecursive(true));
List<AlluxioURI> expected = Lists.newArrayList(nestedDir, thirdLevelFile);
List<AlluxioURI> result = mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyContext.defaults());
Collections.sort(expected);
Collections.sort(result);
Assert.assertEquals(expected, result);
}
use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method before.
@Before
public final void before() throws Exception {
mFileSystemMaster = mLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
mFileSystem = FileSystem.Factory.create(ServerConfiguration.global());
CreateDirectoryPOptions dirOptions = CreateDirectoryPOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
CreateFilePOptions fileOptions = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
mFileSystem.createDirectory(DIRECTORY, dirOptions);
mFileSystem.createFile(FILE, fileOptions).close();
}
use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method persistDirectoryLater.
/**
* Tests journalling of creating directories with MUST_CACHE, then creating the same directories
* again with CACHE_THROUGH and AllowExists=true.
*/
@Test
public void persistDirectoryLater() throws Exception {
String[] directories = new String[] { "/d11", "/d11/d21", "/d11/d22", "/d12", "/d12/d21", "/d12/d22" };
CreateDirectoryPOptions options = CreateDirectoryPOptions.newBuilder().setRecursive(true).setWriteType(WritePType.MUST_CACHE).build();
for (String directory : directories) {
mFileSystem.createDirectory(new AlluxioURI(directory), options);
}
options = options.toBuilder().setWriteType(WritePType.CACHE_THROUGH).setAllowExists(true).build();
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);
}
use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.
the class BaseFileSystem method createDirectory.
@Override
public void createDirectory(AlluxioURI path, CreateDirectoryPOptions options) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException {
checkUri(path);
rpc(client -> {
CreateDirectoryPOptions mergedOptions = FileSystemOptions.createDirectoryDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
client.createDirectory(path, mergedOptions);
LOG.debug("Created directory {}, options: {}", path.getPath(), mergedOptions);
return null;
});
}
use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.
the class CreateDirectoryContext method mergeFrom.
// TODO(zac): Consider renaming mergeFrom to disambiguate between POptions mergeFrom since
// this method and the gRPC version have different functionality.
/**
* Merges and embeds the given {@link CreateDirectoryPOptions} with the corresponding master
* options.
*
* @param optionsBuilder Builder for proto {@link CreateDirectoryPOptions} to merge with defaults
* @return the instance of {@link CreateDirectoryContext} with default values for master
*/
public static CreateDirectoryContext mergeFrom(CreateDirectoryPOptions.Builder optionsBuilder) {
CreateDirectoryPOptions masterOptions = FileSystemOptions.createDirectoryDefaults(ServerConfiguration.global());
CreateDirectoryPOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
return create(mergedOptionsBuilder);
}
Aggregations