Search in sources :

Example 11 with CreateFileOptions

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

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

Example 13 with CreateFileOptions

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

the class FileSystemMasterTest method setTtlForFileWithNoTtl.

/**
   * Tests that an exception is thrown when trying to get information about a file after it has been
   * deleted because of a TTL of 0.
   */
@Test
public void setTtlForFileWithNoTtl() throws Exception {
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setRecursive(true);
    long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, options);
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
    // Since no TTL is set, the file should not be deleted.
    Assert.assertEquals(fileId, mFileSystemMaster.getFileInfo(NESTED_FILE_URI).getFileId());
    mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeOptions.defaults().setTtl(0));
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
    // TTL is set to 0, the file should have been deleted during last TTL check.
    mThrown.expect(FileDoesNotExistException.class);
    mFileSystemMaster.getFileInfo(fileId);
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) Test(org.junit.Test)

Example 14 with CreateFileOptions

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

the class FileSystemMasterTest method ttlFileDelete.

/**
   * Tests that an exception is in the
   * {@link FileSystemMaster#createFile(AlluxioURI, CreateFileOptions)} with a TTL set in the
   * {@link CreateFileOptions} after the TTL check was done once.
   */
@Test
public void ttlFileDelete() throws Exception {
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setRecursive(true).setTtl(0);
    long fileId = mFileSystemMaster.createFile(NESTED_FILE_URI, options);
    FileInfo fileInfo = mFileSystemMaster.getFileInfo(fileId);
    Assert.assertEquals(fileInfo.getFileId(), fileId);
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
    mThrown.expect(FileDoesNotExistException.class);
    mFileSystemMaster.getFileInfo(fileId);
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) FileInfo(alluxio.wire.FileInfo) Test(org.junit.Test)

Example 15 with CreateFileOptions

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

the class InodeTreeTest method createFileWithInvalidBlockSize.

/**
   * Tests that an exception is thrown when trying to create a file with invalid block size.
   */
@Test
public void createFileWithInvalidBlockSize() throws Exception {
    mThrown.expect(BlockInfoException.class);
    mThrown.expectMessage("Invalid block size 0");
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(0);
    createPath(mTree, TEST_URI, options);
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) 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