use of alluxio.master.file.contexts.CreateFileContext in project alluxio by Alluxio.
the class FileSystemMasterTest method renameToNonExistentParent.
@Test
public void renameToNonExistentParent() throws Exception {
CreateFileContext context = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setRecursive(true));
mFileSystemMaster.createFile(NESTED_URI, context);
try {
mFileSystemMaster.rename(NESTED_URI, new AlluxioURI("/testDNE/b"), RenameContext.defaults());
fail("Rename to a non-existent parent path should not succeed.");
} catch (FileDoesNotExistException e) {
// Expected case.
}
}
use of alluxio.master.file.contexts.CreateFileContext in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method lastModificationTimeCreateFile.
@Test
public void lastModificationTimeCreateFile() throws Exception {
mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryContext.defaults());
long opTimeMs = TEST_TIME_MS;
CreateFileContext context = CreateFileContext.defaults().setOperationTimeMs(opTimeMs);
mFsMaster.createFile(new AlluxioURI("/testFolder/testFile"), context);
FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder")));
Assert.assertEquals(opTimeMs, folderInfo.getLastModificationTimeMs());
Assert.assertEquals(opTimeMs, folderInfo.getLastAccessTimeMs());
}
use of alluxio.master.file.contexts.CreateFileContext in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method renameToDeeper.
@Test
public void renameToDeeper() throws Exception {
CreateFileContext createFileOptions = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setRecursive(true));
CreateDirectoryContext createDirectoryContext = CreateDirectoryContext.mergeFrom(CreateDirectoryPOptions.newBuilder().setRecursive(true));
mThrown.expect(InvalidPathException.class);
mFsMaster.createDirectory(new AlluxioURI("/testDir1/testDir2"), createDirectoryContext);
mFsMaster.createFile(new AlluxioURI("/testDir1/testDir2/testDir3/testFile3"), createFileOptions);
mFsMaster.rename(new AlluxioURI("/testDir1/testDir2"), new AlluxioURI("/testDir1/testDir2/testDir3/testDir4"), RenameContext.defaults());
}
use of alluxio.master.file.contexts.CreateFileContext 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"), CreateDirectoryContext.defaults());
long ttl = 1;
CreateFileContext context = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl)));
mFsMaster.createFile(srcPath, context);
mFsMaster.rename(srcPath, dstPath, RenameContext.defaults().setOperationTimeMs(TEST_TIME_MS));
FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile2")));
Assert.assertEquals(ttl, folderInfo.getTtl());
}
use of alluxio.master.file.contexts.CreateFileContext in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method ttlExpiredCreateFileWithFreeAction.
@Test
public void ttlExpiredCreateFileWithFreeAction() throws Exception {
mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryContext.defaults());
long ttl = 1;
CreateFileContext context = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl).setTtlAction(alluxio.grpc.TtlAction.FREE))).setWriteType(WriteType.CACHE_THROUGH);
long fileId = mFsMaster.createFile(new AlluxioURI("/testFolder/testFile1"), context).getFileId();
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());
}
Aggregations