Search in sources :

Example 31 with FileInfo

use of alluxio.wire.FileInfo 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);
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) FileInfo(alluxio.wire.FileInfo) HashSet(java.util.HashSet) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 32 with FileInfo

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

the class FileSystemMasterIntegrationTest method lastModificationTimeCompleteFile.

@Test
public void lastModificationTimeCompleteFile() throws Exception {
    long fileId = mFsMaster.createFile(new AlluxioURI("/testFile"), CreateFileOptions.defaults());
    long opTimeMs = TEST_TIME_MS;
    mFsMaster.completeFile(new AlluxioURI("/testFile"), CompleteFileOptions.defaults().setOperationTimeMs(opTimeMs).setUfsLength(0));
    FileInfo fileInfo = mFsMaster.getFileInfo(fileId);
    Assert.assertEquals(opTimeMs, fileInfo.getLastModificationTimeMs());
}
Also used : FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 33 with FileInfo

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

the class FileSystemMasterIntegrationTest method concurrentCreateJournal.

// TODO(calvin): This test currently relies on the fact the HDFS client is a cached instance to
// avoid invalid lease exception. This should be fixed.
@Ignore
@Test
public void concurrentCreateJournal() throws Exception {
    // Makes sure the file id's are the same between a master info and the journal it creates
    for (int i = 0; i < 5; i++) {
        ConcurrentCreator concurrentCreator = new ConcurrentCreator(DEPTH, CONCURRENCY_DEPTH, ROOT_PATH);
        concurrentCreator.call();
        FileSystemMaster fsMaster = createFileSystemMasterFromJournal();
        for (FileInfo info : mFsMaster.listStatus(new AlluxioURI("/"), ListStatusOptions.defaults())) {
            AlluxioURI path = new AlluxioURI(info.getPath());
            Assert.assertEquals(mFsMaster.getFileId(path), fsMaster.getFileId(path));
        }
        before();
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 34 with FileInfo

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

the class FileSystemMasterIntegrationTest method ttlCreateFile.

@Test
public void ttlCreateFile() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 100;
    CreateFileOptions options = CreateFileOptions.defaults().setTtl(ttl);
    options.setTtlAction(TtlAction.FREE);
    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/testFile")));
    Assert.assertEquals(ttl, folderInfo.getTtl());
    Assert.assertEquals(TtlAction.FREE, folderInfo.getTtlAction());
}
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 35 with FileInfo

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

the class FileSystemMasterIntegrationTest method ttlRename.

@Test
public void ttlRename() throws Exception {
    AlluxioURI srcPath = new AlluxioURI("/testFolder/testFile1");
    AlluxioURI dstPath = new AlluxioURI("/testFolder/testFile2");
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 1;
    CreateFileOptions createOptions = CreateFileOptions.defaults().setTtl(ttl);
    mFsMaster.createFile(srcPath, createOptions);
    RenameOptions renameOptions = RenameOptions.defaults().setOperationTimeMs(TEST_TIME_MS);
    mFsMaster.rename(srcPath, dstPath, renameOptions);
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile2")));
    Assert.assertEquals(ttl, folderInfo.getTtl());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) RenameOptions(alluxio.master.file.options.RenameOptions) 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