Search in sources :

Example 71 with FileInfo

use of alluxio.wire.FileInfo in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method lastModificationTimeCreateFile.

@Test
public void lastModificationTimeCreateFile() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long opTimeMs = TEST_TIME_MS;
    CreateFileOptions options = CreateFileOptions.defaults().setOperationTimeMs(opTimeMs);
    try (LockedInodePath inodePath = mInodeTree.lockInodePath(new AlluxioURI("/testFolder/testFile"), InodeTree.LockMode.WRITE)) {
        mFsMaster.createFileInternal(inodePath, options);
    }
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder")));
    Assert.assertEquals(opTimeMs, folderInfo.getLastModificationTimeMs());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) LockedInodePath(alluxio.master.file.meta.LockedInodePath) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 72 with FileInfo

use of alluxio.wire.FileInfo in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method ttlExpiredCreateFileWithFreeActionTest.

@Test
public void ttlExpiredCreateFileWithFreeActionTest() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 1;
    CreateFileOptions options = CreateFileOptions.defaults().setPersisted(true).setTtl(ttl).setTtlAction(TtlAction.FREE);
    long fileId = mFsMaster.createFile(new AlluxioURI("/testFolder/testFile1"), options);
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile1")));
    Assert.assertEquals(fileId, folderInfo.getFileId());
    Assert.assertEquals(ttl, folderInfo.getTtl());
    Assert.assertEquals(TtlAction.FREE, folderInfo.getTtlAction());
    // Sleep for the ttl expiration.
    CommonUtils.sleepMs(2 * TTL_CHECKER_INTERVAL_MS);
    HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS);
    HeartbeatScheduler.schedule(HeartbeatContext.MASTER_TTL_CHECK);
    HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS);
    FileInfo fileInfo = mFsMaster.getFileInfo(fileId);
    Assert.assertEquals(Constants.NO_TTL, fileInfo.getTtl());
    Assert.assertEquals(TtlAction.DELETE, fileInfo.getTtlAction());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 73 with FileInfo

use of alluxio.wire.FileInfo in project alluxio by Alluxio.

the class FileSystemClientRestApiTest method getStatus.

@Test
public void getStatus() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    writeFile(uri, null);
    String result = new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.GET_STATUS, NO_PARAMS, HttpMethod.POST, TestCaseOptions.defaults().setBody(GetStatusOptions.defaults())).call();
    FileInfo fileInfo = new ObjectMapper().readValue(result, FileInfo.class);
    Assert.assertEquals(uri.getPath(), fileInfo.getPath());
    Assert.assertEquals(0, fileInfo.getLength());
}
Also used : FileInfo(alluxio.wire.FileInfo) TestCase(alluxio.rest.TestCase) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 74 with FileInfo

use of alluxio.wire.FileInfo in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method clientFileInfoDirectory.

@Test
public void clientFileInfoDirectory() throws Exception {
    AlluxioURI path = new AlluxioURI("/testFolder");
    mFsMaster.createDirectory(path, CreateDirectoryOptions.defaults());
    long fileId = mFsMaster.getFileId(path);
    FileInfo fileInfo = mFsMaster.getFileInfo(fileId);
    Assert.assertEquals("testFolder", fileInfo.getName());
    Assert.assertEquals(1, fileInfo.getFileId());
    Assert.assertEquals(0, fileInfo.getLength());
    Assert.assertFalse(fileInfo.isCacheable());
    Assert.assertTrue(fileInfo.isCompleted());
    Assert.assertTrue(fileInfo.isFolder());
    Assert.assertFalse(fileInfo.isPersisted());
    Assert.assertFalse(fileInfo.isPinned());
    Assert.assertEquals("", fileInfo.getOwner());
    Assert.assertEquals(0755, (short) fileInfo.getMode());
}
Also used : FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 75 with FileInfo

use of alluxio.wire.FileInfo in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method createDirectory.

@Test
public void createDirectory() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    FileInfo fileInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder")));
    Assert.assertTrue(fileInfo.isFolder());
    Assert.assertEquals("", fileInfo.getOwner());
    Assert.assertEquals(0755, (short) fileInfo.getMode());
}
Also used : FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

FileInfo (alluxio.wire.FileInfo)81 AlluxioURI (alluxio.AlluxioURI)60 Test (org.junit.Test)54 URIStatus (alluxio.client.file.URIStatus)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 CreateFileOptions (alluxio.master.file.options.CreateFileOptions)9 ArrayList (java.util.ArrayList)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)7 RestApiTest (alluxio.rest.RestApiTest)7 TestCase (alluxio.rest.TestCase)7 SetAndRestoreAuthenticatedUser (alluxio.SetAndRestoreAuthenticatedUser)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 FileSystemMaster (alluxio.master.file.FileSystemMaster)4 CreateOptions (alluxio.underfs.options.CreateOptions)4 OutputStream (java.io.OutputStream)4 InvalidPathException (alluxio.exception.InvalidPathException)3 FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)3 LockedInodePath (alluxio.master.file.meta.LockedInodePath)3 FileBlockInfo (alluxio.wire.FileBlockInfo)3 IOException (java.io.IOException)3