Search in sources :

Example 6 with CreateFileOptions

use of alluxio.master.file.options.CreateFileOptions in project alluxio by Alluxio.

the class FileSystemMasterTest method setNoTtlForFileWithTtl.

/**
   * Tests that the original TTL is removed after setting it to {@link Constants#NO_TTL} for a file.
   */
@Test
public void setNoTtlForFileWithTtl() throws Exception {
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setRecursive(true).setTtl(0);
    long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, options);
    // After setting TTL to NO_TTL, the original TTL will be removed, and the file will not be
    // deleted during next TTL check.
    mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeOptions.defaults().setTtl(Constants.NO_TTL));
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
    Assert.assertEquals(fileId, mFileSystemMaster.getFileInfo(fileId).getFileId());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) Test(org.junit.Test)

Example 7 with CreateFileOptions

use of alluxio.master.file.options.CreateFileOptions in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method ttlExpiredCreateFile.

@Test
public void ttlExpiredCreateFile() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 1;
    CreateFileOptions options = CreateFileOptions.defaults().setTtl(ttl);
    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());
    // Sleep for the ttl expiration.
    CommonUtils.sleepMs(2 * TTL_CHECKER_INTERVAL_MS);
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
    mThrown.expect(FileDoesNotExistException.class);
    mFsMaster.getFileInfo(fileId);
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 8 with CreateFileOptions

use of alluxio.master.file.options.CreateFileOptions in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method renameToDeeper.

@Test
public void renameToDeeper() throws Exception {
    CreateFileOptions createFileOptions = CreateFileOptions.defaults().setRecursive(true);
    CreateDirectoryOptions createDirectoryOptions = CreateDirectoryOptions.defaults().setRecursive(true);
    mThrown.expect(InvalidPathException.class);
    mFsMaster.createDirectory(new AlluxioURI("/testDir1/testDir2"), createDirectoryOptions);
    mFsMaster.createFile(new AlluxioURI("/testDir1/testDir2/testDir3/testFile3"), createFileOptions);
    mFsMaster.rename(new AlluxioURI("/testDir1/testDir2"), new AlluxioURI("/testDir1/testDir2/testDir3/testDir4"), RenameOptions.defaults());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) CreateDirectoryOptions(alluxio.master.file.options.CreateDirectoryOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 9 with CreateFileOptions

use of alluxio.master.file.options.CreateFileOptions in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method ls.

@Test
public void ls() throws Exception {
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(64);
    for (int i = 0; i < 10; i++) {
        mFsMaster.createDirectory(new AlluxioURI("/i" + i), CreateDirectoryOptions.defaults());
        for (int j = 0; j < 10; j++) {
            mFsMaster.createFile(new AlluxioURI("/i" + i + "/j" + j), options);
        }
    }
    Assert.assertEquals(1, mFsMaster.listStatus(new AlluxioURI("/i0/j0"), ListStatusOptions.defaults()).size());
    for (int i = 0; i < 10; i++) {
        Assert.assertEquals(10, mFsMaster.listStatus(new AlluxioURI("/i" + i), ListStatusOptions.defaults()).size());
    }
    Assert.assertEquals(10, mFsMaster.listStatus(new AlluxioURI("/"), ListStatusOptions.defaults()).size());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 10 with CreateFileOptions

use of alluxio.master.file.options.CreateFileOptions 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)

Aggregations

CreateFileOptions (alluxio.master.file.options.CreateFileOptions)24 Test (org.junit.Test)20 AlluxioURI (alluxio.AlluxioURI)13 FileInfo (alluxio.wire.FileInfo)9 CreateDirectoryOptions (alluxio.master.file.options.CreateDirectoryOptions)4 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)3 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 LockedInodePath (alluxio.master.file.meta.LockedInodePath)2 Mode (alluxio.security.authorization.Mode)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2 ArrayList (java.util.ArrayList)2 SetAndRestoreAuthenticatedUser (alluxio.SetAndRestoreAuthenticatedUser)1 BlockInfoException (alluxio.exception.BlockInfoException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 CompleteFileOptions (alluxio.master.file.options.CompleteFileOptions)1 RenameOptions (alluxio.master.file.options.RenameOptions)1 MkdirsOptions (alluxio.underfs.options.MkdirsOptions)1 HashSet (java.util.HashSet)1