use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method notAFile.
/**
* Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyOptions)} method
* when a file does not exist as a file in the under storage.
*/
@Test
public void notAFile() throws Exception {
String ufsFile = mFileSystem.getStatus(FILE).getUfsPath();
UnderFileSystem ufs = UnderFileSystem.Factory.get(ufsFile);
ufs.deleteFile(ufsFile);
ufs.mkdirs(ufsFile);
List<AlluxioURI> expected = Lists.newArrayList(FILE);
Assert.assertEquals(expected, mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyOptions.defaults()));
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method notADirectory.
/**
* Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyOptions)} method
* when a directory does not exist as a directory in the under storage.
*/
@Test
public void notADirectory() throws Exception {
String ufsDirectory = mFileSystem.getStatus(DIRECTORY).getUfsPath();
UnderFileSystem ufs = UnderFileSystem.Factory.get(ufsDirectory);
ufs.deleteDirectory(ufsDirectory, DeleteOptions.defaults().setRecursive(true));
ufs.create(ufsDirectory).close();
List<AlluxioURI> expected = Lists.newArrayList(DIRECTORY, FILE);
List<AlluxioURI> result = mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyOptions.defaults());
Collections.sort(expected);
Collections.sort(result);
Assert.assertEquals(expected, result);
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class CheckConsistencyIntegrationTest method incorrectFileSize.
/**
* Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyOptions)} method
* when a file is not the correct size.
*/
@Test
public void incorrectFileSize() throws Exception {
String ufsFile = mFileSystem.getStatus(FILE).getUfsPath();
UnderFileSystem ufs = UnderFileSystem.Factory.get(ufsFile);
ufs.deleteFile(ufsFile);
OutputStream out = ufs.create(ufsFile);
out.write(1);
out.close();
List<AlluxioURI> expected = Lists.newArrayList(FILE);
Assert.assertEquals(expected, mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyOptions.defaults()));
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class ConcurrentFileSystemMasterTest method sameFileConcurrentRename.
/**
* Tests that many threads concurrently renaming the same file will only succeed once.
*/
@Test
public void sameFileConcurrentRename() throws Exception {
int numThreads = CONCURRENCY_FACTOR;
final AlluxioURI[] srcs = new AlluxioURI[numThreads];
final AlluxioURI[] dsts = new AlluxioURI[numThreads];
for (int i = 0; i < numThreads; i++) {
srcs[i] = new AlluxioURI("/file");
dsts[i] = new AlluxioURI("/renamed" + i);
}
// Create the one source file
mFileSystem.createFile(srcs[0], sCreatePersistedFileOptions).close();
int errors = concurrentRename(srcs, dsts);
// We should get an error for all but 1 rename
Assert.assertEquals(numThreads - 1, errors);
List<URIStatus> files = mFileSystem.listStatus(new AlluxioURI("/"));
// Only one renamed file should exist
Assert.assertEquals(1, files.size());
Assert.assertTrue(files.get(0).getName().startsWith("renamed"));
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class AlluxioShellUtilsTest method getPaths.
/**
* Gets all the file paths that match the inputPath depending on fsType.
*
* @param path the input path
* @param fsType the type of file system
* @return a list of files that matches inputPath
*/
public List<String> getPaths(String path, FsType fsType) throws IOException, TException {
List<String> ret = null;
if (fsType == FsType.TFS) {
List<AlluxioURI> tPaths = AlluxioShellUtils.getAlluxioURIs(mFileSystem, new AlluxioURI(path));
ret = new ArrayList<>(tPaths.size());
for (AlluxioURI tPath : tPaths) {
ret.add(tPath.getPath());
}
} else if (fsType == FsType.LOCAL) {
List<File> tPaths = AlluxioShellUtils.getFiles(path);
ret = new ArrayList<>(tPaths.size());
for (File tPath : tPaths) {
ret.add(tPath.getPath());
}
}
Collections.sort(ret);
return ret;
}
Aggregations