use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class BlockServiceHandlerIntegrationTest method cancelBlock.
// Tests that cancelling a block will remove the temporary file
@Test
public void cancelBlock() throws Exception {
mFileSystem.createFile(new AlluxioURI("/testFile")).close();
URIStatus file = mFileSystem.getStatus(new AlluxioURI("/testFile"));
final int writeTier = Constants.FIRST_TIER;
final int blockSize = (int) WORKER_CAPACITY_BYTES / 2;
final long blockId = BlockId.createBlockId(BlockId.getContainerId(file.getFileId()), 0);
String filename = mBlockWorkerServiceHandler.requestBlockLocation(SESSION_ID, blockId, blockSize, writeTier);
createBlockFile(filename, blockSize);
mBlockWorkerServiceHandler.cancelBlock(SESSION_ID, blockId);
// The block should not exist after being cancelled
Assert.assertFalse(new File(filename).exists());
// The master should not have recorded any used space after the block is cancelled
HeartbeatScheduler.execute(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertEquals(0, mBlockMasterClient.getUsedBytes());
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class BlockServiceHandlerIntegrationTest method lockBlockFailure.
// Tests that lock block returns error on failure
@Test
public void lockBlockFailure() throws Exception {
mFileSystem.createFile(new AlluxioURI("/testFile")).close();
URIStatus file = mFileSystem.getStatus(new AlluxioURI("/testFile"));
final long blockId = BlockId.createBlockId(BlockId.getContainerId(file.getFileId()), 0);
Exception exception = null;
try {
mBlockWorkerServiceHandler.lockBlock(blockId, SESSION_ID, new LockBlockTOptions());
} catch (AlluxioTException e) {
exception = e;
}
// A file does not exist exception should have been thrown
Assert.assertNotNull(exception);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class LoadCommandTest method loadFile.
@Test
public void loadFile() throws IOException, AlluxioException {
FileSystemTestUtils.createByteFile(mFileSystem, "/testFile", WriteType.THROUGH, 10);
AlluxioURI uri = new AlluxioURI("/testFile");
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertFalse(status.getInMemoryPercentage() == 100);
// Testing loading of a single file
mFsShell.run("load", "/testFile");
status = mFileSystem.getStatus(uri);
Assert.assertTrue(status.getInMemoryPercentage() == 100);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class LoadCommandTest method loadDir.
@Test
public void loadDir() throws IOException, AlluxioException {
FileSystemTestUtils.createByteFile(mFileSystem, "/testRoot/testFileA", WriteType.THROUGH, 10);
FileSystemTestUtils.createByteFile(mFileSystem, "/testRoot/testFileB", WriteType.MUST_CACHE, 10);
AlluxioURI uriA = new AlluxioURI("/testRoot/testFileA");
AlluxioURI uriB = new AlluxioURI("/testRoot/testFileB");
URIStatus statusA = mFileSystem.getStatus(uriA);
URIStatus statusB = mFileSystem.getStatus(uriB);
Assert.assertFalse(statusA.getInMemoryPercentage() == 100);
Assert.assertTrue(statusB.getInMemoryPercentage() == 100);
// Testing loading of a directory
mFsShell.run("load", "/testRoot");
statusA = mFileSystem.getStatus(uriA);
statusB = mFileSystem.getStatus(uriB);
Assert.assertTrue(statusA.getInMemoryPercentage() == 100);
Assert.assertTrue(statusB.getInMemoryPercentage() == 100);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class LsCommandTest method lsDirectoryAsPlainFileNoAcl.
/**
* Tests ls -d command when security is not enabled.
*/
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "false", PropertyKey.Name.SECURITY_AUTHENTICATION_TYPE, "NOSASL" })
public void lsDirectoryAsPlainFileNoAcl() throws IOException, AlluxioException {
URIStatus[] files = createFiles();
mFsShell.run("ls", "-d", "/testRoot");
URIStatus dirStatus = mFileSystem.getStatus(new AlluxioURI("/testRoot/"));
String expected = "";
expected += getLsNoAclResultStr("/testRoot", dirStatus.getCreationTimeMs(), 3, /* number of direct children under /testRoot/ dir */
LsCommand.STATE_FOLDER);
Assert.assertEquals(expected, mOutput.toString());
}
Aggregations