use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class CopyFromLocalCommandTest method copyFromLocalLarge.
@Test
public void copyFromLocalLarge() throws IOException, AlluxioException {
File testFile = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testFile");
testFile.createNewFile();
FileOutputStream fos = new FileOutputStream(testFile);
byte[] toWrite = BufferUtils.getIncreasingByteArray(SIZE_BYTES);
fos.write(toWrite);
fos.close();
mFsShell.run("copyFromLocal", testFile.getAbsolutePath(), "/testFile");
Assert.assertEquals(getCommandOutput(new String[] { "copyFromLocal", testFile.getAbsolutePath(), "/testFile" }), mOutput.toString());
AlluxioURI uri = new AlluxioURI("/testFile");
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertNotNull(status);
Assert.assertEquals(SIZE_BYTES, status.getLength());
try (FileInStream tfis = mFileSystem.openFile(uri, OpenFileOptions.defaults().setReadType(ReadType.NO_CACHE))) {
byte[] read = new byte[SIZE_BYTES];
tfis.read(read);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(SIZE_BYTES, read));
}
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method deleteEmptyDirectory.
@Test
public void deleteEmptyDirectory() throws Exception {
mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
Assert.assertEquals(1, mFsMaster.getFileId(new AlluxioURI("/testFolder")));
mFsMaster.delete(new AlluxioURI("/testFolder"), DeleteOptions.defaults().setRecursive(true));
Assert.assertEquals(IdUtils.INVALID_FILE_ID, mFsMaster.getFileId(new AlluxioURI("/testFolder")));
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method concurrentCreateDelete.
@Test
public void concurrentCreateDelete() throws Exception {
List<Future<?>> futures = new ArrayList<>();
AlluxioURI directory = new AlluxioURI("/dir");
AlluxioURI[] files = new AlluxioURI[10];
final int numThreads = 8;
final int testDurationMs = 3000;
for (int i = 0; i < 10; i++) {
files[i] = directory.join("file_" + i);
}
mFsMaster.createDirectory(directory, CreateDirectoryOptions.defaults());
AtomicBoolean stopThreads = new AtomicBoolean(false);
CyclicBarrier barrier = new CyclicBarrier(numThreads);
ExecutorService threadPool = Executors.newCachedThreadPool();
try {
for (int i = 0; i < numThreads; i++) {
futures.add(threadPool.submit(new ConcurrentCreateDelete(barrier, stopThreads, files)));
}
CommonUtils.sleepMs(testDurationMs);
stopThreads.set(true);
for (Future<?> future : futures) {
future.get();
}
// Stop Alluxio.
mLocalAlluxioClusterResource.get().stopFS();
// Create the master using the existing journal.
createFileSystemMasterFromJournal();
} finally {
threadPool.shutdownNow();
threadPool.awaitTermination(SHUTDOWN_TIME_MS, TimeUnit.MILLISECONDS);
}
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method createFileInvalidPathTest2.
@Test
public void createFileInvalidPathTest2() throws Exception {
mThrown.expect(FileAlreadyExistsException.class);
mFsMaster.createFile(new AlluxioURI("/"), CreateFileOptions.defaults());
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method listFiles.
@Test
public void listFiles() throws Exception {
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(64);
HashSet<Long> ids = new HashSet<>();
HashSet<Long> dirIds = new HashSet<>();
for (int i = 0; i < 10; i++) {
AlluxioURI dir = new AlluxioURI("/i" + i);
mFsMaster.createDirectory(dir, CreateDirectoryOptions.defaults());
dirIds.add(mFsMaster.getFileId(dir));
for (int j = 0; j < 10; j++) {
ids.add(mFsMaster.createFile(dir.join("j" + j), options));
}
}
HashSet<Long> listedIds = new HashSet<>();
HashSet<Long> listedDirIds = new HashSet<>();
List<FileInfo> infoList = mFsMaster.listStatus(new AlluxioURI("/"), ListStatusOptions.defaults());
for (FileInfo info : infoList) {
long id = info.getFileId();
listedDirIds.add(id);
for (FileInfo fileInfo : mFsMaster.listStatus(new AlluxioURI(info.getPath()), ListStatusOptions.defaults())) {
listedIds.add(fileInfo.getFileId());
}
}
Assert.assertEquals(ids, listedIds);
Assert.assertEquals(dirIds, listedDirIds);
}
Aggregations