use of alluxio.client.file.options.CreateDirectoryOptions in project alluxio by Alluxio.
the class FileSystemIntegrationTest method mkdir.
@Test
public void mkdir() throws Exception {
String uniqPath = PathUtils.uniqPath();
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true);
for (int k = 0; k < 10; k++) {
mFileSystem.createDirectory(new AlluxioURI(uniqPath + k), options);
try {
mFileSystem.createDirectory(new AlluxioURI(uniqPath + k), options);
Assert.fail("createDirectory should throw FileAlreadyExistsException");
} catch (FileAlreadyExistsException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(uniqPath + k));
}
}
}
use of alluxio.client.file.options.CreateDirectoryOptions in project alluxio by Alluxio.
the class MkdirCommand method run.
@Override
public void run(CommandLine cl) throws AlluxioException, IOException {
String[] args = cl.getArgs();
for (String path : args) {
AlluxioURI inputPath = new AlluxioURI(path);
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true);
mFileSystem.createDirectory(inputPath, options);
System.out.println("Successfully created directory " + inputPath);
}
}
use of alluxio.client.file.options.CreateDirectoryOptions in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method largeTree.
/**
* Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyOptions)} method
* when some files are consistent in a larger inode tree.
*/
@Test
public void largeTree() throws Exception {
CreateDirectoryOptions dirOptions = CreateDirectoryOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
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.get(ufsDirectory);
ufs.deleteDirectory(ufsDirectory, DeleteOptions.defaults().setRecursive(true));
List<AlluxioURI> expected = Lists.newArrayList(nestedDir, thirdLevelFile);
List<AlluxioURI> result = mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyOptions.defaults());
Collections.sort(expected);
Collections.sort(result);
Assert.assertEquals(expected, result);
}
use of alluxio.client.file.options.CreateDirectoryOptions in project alluxio by Alluxio.
the class JournalIntegrationTest method delete.
/**
* Tests file and directory creation and deletion.
*/
@Test
public void delete() throws Exception {
CreateDirectoryOptions recMkdir = CreateDirectoryOptions.defaults().setRecursive(true);
DeleteOptions recDelete = DeleteOptions.defaults().setRecursive(true);
for (int i = 0; i < 10; i++) {
String dirPath = "/i" + i;
mFileSystem.createDirectory(new AlluxioURI(dirPath), recMkdir);
for (int j = 0; j < 10; j++) {
CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes((i + j + 1) * 64);
String filePath = dirPath + "/j" + j;
mFileSystem.createFile(new AlluxioURI(filePath), option).close();
if (j >= 5) {
mFileSystem.delete(new AlluxioURI(filePath), recDelete);
}
}
if (i >= 5) {
mFileSystem.delete(new AlluxioURI(dirPath), recDelete);
}
}
mLocalAlluxioCluster.stopFS();
deleteTestUtil();
deleteFsMasterJournalLogs();
deleteTestUtil();
}
use of alluxio.client.file.options.CreateDirectoryOptions in project alluxio by Alluxio.
the class AbstractFileSystem method mkdirs.
/**
* Attempts to create a folder with the specified path. Parent directories will be created.
*
* @param path path to create
* @param permission permissions to grant the created folder
* @return true if the indicated folder is created successfully or already exists
* @throws IOException if the folder cannot be created
*/
@Override
public boolean mkdirs(Path path, FsPermission permission) throws IOException {
LOG.debug("mkdirs({}, {})", path, permission);
if (mStatistics != null) {
mStatistics.incrementWriteOps(1);
}
AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path));
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true).setAllowExists(true).setMode(new Mode(permission.toShort()));
try {
mFileSystem.createDirectory(uri, options);
return true;
} catch (AlluxioException e) {
throw new IOException(e);
}
}
Aggregations