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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations