Search in sources :

Example 31 with URIStatus

use of alluxio.client.file.URIStatus in project alluxio by Alluxio.

the class MkdirCommandTest method mkdirComplexPath.

@Test
public void mkdirComplexPath() throws IOException, AlluxioException {
    mFsShell.run("mkdir", "/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File");
    URIStatus status = mFileSystem.getStatus(new AlluxioURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"));
    Assert.assertNotNull(status);
    Assert.assertEquals(getCommandOutput(new String[] { "mkdir", "/Complex!@#$%^&*()-_=+[]{};\"'<>," + ".?/File" }), mOutput.toString());
    Assert.assertTrue(status.isFolder());
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 32 with URIStatus

use of alluxio.client.file.URIStatus in project alluxio by Alluxio.

the class MkdirCommandTest method mkdirShortPath.

@Test
public void mkdirShortPath() throws IOException, AlluxioException {
    mFsShell.run("mkdir", "/root/testFile1");
    URIStatus status = mFileSystem.getStatus(new AlluxioURI("/root/testFile1"));
    Assert.assertNotNull(status);
    Assert.assertEquals(getCommandOutput(new String[] { "mkdir", "/root/testFile1" }), mOutput.toString());
    Assert.assertTrue(status.isFolder());
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 33 with URIStatus

use of alluxio.client.file.URIStatus in project alluxio by Alluxio.

the class MkdirCommandTest method mkdirMultiPath.

@Test
public void mkdirMultiPath() throws IOException, AlluxioException {
    String path1 = "/testDir1";
    String path2 = "/testDir2";
    String path3 = "/testDir2/testDir2.1";
    Assert.assertEquals(0, mFsShell.run("mkdir", path1, path2, path3));
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(path1));
    Assert.assertNotNull(status);
    Assert.assertTrue(status.isFolder());
    status = mFileSystem.getStatus(new AlluxioURI(path2));
    Assert.assertNotNull(status);
    Assert.assertTrue(status.isFolder());
    status = mFileSystem.getStatus(new AlluxioURI(path3));
    Assert.assertNotNull(status);
    Assert.assertTrue(status.isFolder());
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) AbstractAlluxioShellTest(alluxio.shell.AbstractAlluxioShellTest)

Example 34 with URIStatus

use of alluxio.client.file.URIStatus in project alluxio by Alluxio.

the class BlockServiceHandlerIntegrationTest method eviction.

// Tests that files are evicted when there is not enough space in the worker.
@Test
public void eviction() throws Exception {
    final int blockSize = (int) WORKER_CAPACITY_BYTES / 2;
    AlluxioURI file1 = new AlluxioURI("/file1");
    FileSystemTestUtils.createByteFile(mFileSystem, file1, WriteType.MUST_CACHE, blockSize);
    // File should be in memory after it is written with MUST_CACHE
    URIStatus fileInfo1 = mFileSystem.getStatus(file1);
    Assert.assertEquals(100, fileInfo1.getInMemoryPercentage());
    AlluxioURI file2 = new AlluxioURI("/file2");
    FileSystemTestUtils.createByteFile(mFileSystem, file2, WriteType.MUST_CACHE, blockSize);
    // Both file 1 and 2 should be in memory since the combined size is not larger than worker space
    fileInfo1 = mFileSystem.getStatus(file1);
    URIStatus fileInfo2 = mFileSystem.getStatus(file2);
    Assert.assertEquals(100, fileInfo1.getInMemoryPercentage());
    Assert.assertEquals(100, fileInfo2.getInMemoryPercentage());
    AlluxioURI file3 = new AlluxioURI("/file3");
    FileSystemTestUtils.createByteFile(mFileSystem, file3, WriteType.MUST_CACHE, blockSize);
    HeartbeatScheduler.execute(HeartbeatContext.WORKER_BLOCK_SYNC);
    fileInfo1 = mFileSystem.getStatus(file1);
    fileInfo2 = mFileSystem.getStatus(file2);
    URIStatus fileInfo3 = mFileSystem.getStatus(file3);
    // File 3 should be in memory and one of file 1 or 2 should be in memory
    Assert.assertEquals(100, fileInfo3.getInMemoryPercentage());
    Assert.assertTrue("Exactly one of file1 and file2 should be 100% in memory", fileInfo1.getInMemoryPercentage() == 100 ^ fileInfo2.getInMemoryPercentage() == 100);
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 35 with URIStatus

use of alluxio.client.file.URIStatus in project alluxio by Alluxio.

the class SetTtlCommandTest method setTtlWithDelete.

@Test
public void setTtlWithDelete() throws Exception {
    String filePath = "/testFile";
    FileSystemTestUtils.createByteFile(mFileSystem, filePath, WriteType.MUST_CACHE, 1);
    Assert.assertEquals(Constants.NO_TTL, mFileSystem.getStatus(new AlluxioURI("/testFile")).getTtl());
    AlluxioURI uri = new AlluxioURI("/testFile");
    long ttl = 1000L;
    Assert.assertEquals(0, mFsShell.run("setTtl", "-action", "delete", filePath, String.valueOf(ttl)));
    URIStatus status = mFileSystem.getStatus(uri);
    Assert.assertEquals(ttl, status.getTtl());
    Assert.assertEquals(TtlAction.DELETE, status.getTtlAction());
}
Also used : URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) 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