Search in sources :

Example 26 with URIStatus

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());
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 27 with URIStatus

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);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) URIStatus(alluxio.client.file.URIStatus) LockBlockTOptions(alluxio.thrift.LockBlockTOptions) InvalidPathException(alluxio.exception.InvalidPathException) AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 28 with URIStatus

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);
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 29 with URIStatus

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);
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 30 with URIStatus

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());
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AlluxioShellUtilsTest(alluxio.shell.AlluxioShellUtilsTest) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Aggregations

URIStatus (alluxio.client.file.URIStatus)119 AlluxioURI (alluxio.AlluxioURI)111 Test (org.junit.Test)78 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)23 IOException (java.io.IOException)19 FileInStream (alluxio.client.file.FileInStream)17 ArrayList (java.util.ArrayList)15 AlluxioException (alluxio.exception.AlluxioException)13 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)13 AlluxioShellUtilsTest (alluxio.shell.AlluxioShellUtilsTest)12 FileInfo (alluxio.wire.FileInfo)12 File (java.io.File)10 FileOutStream (alluxio.client.file.FileOutStream)9 FileSystem (alluxio.client.file.FileSystem)7 InvalidPathException (alluxio.exception.InvalidPathException)7 ByteBuffer (java.nio.ByteBuffer)7 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)6 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)5 FileSystemMaster (alluxio.master.file.FileSystemMaster)5 UnderFileSystem (alluxio.underfs.UnderFileSystem)5