Search in sources :

Example 6 with CreateFileContext

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.
    }
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 7 with CreateFileContext

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());
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 8 with CreateFileContext

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());
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) CreateDirectoryContext(alluxio.master.file.contexts.CreateDirectoryContext) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with CreateFileContext

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());
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 10 with CreateFileContext

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());
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

CreateFileContext (alluxio.master.file.contexts.CreateFileContext)26 Test (org.junit.Test)22 AlluxioURI (alluxio.AlluxioURI)14 FileInfo (alluxio.wire.FileInfo)10 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)9 CreateDirectoryContext (alluxio.master.file.contexts.CreateDirectoryContext)5 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)4 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 AccessControlList (alluxio.security.authorization.AccessControlList)2 DefaultAccessControlList (alluxio.security.authorization.DefaultAccessControlList)2 AuthenticatedUserRule (alluxio.AuthenticatedUserRule)1 BlockInfoException (alluxio.exception.BlockInfoException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 CompleteFileContext (alluxio.master.file.contexts.CompleteFileContext)1 LockedInodePath (alluxio.master.file.meta.LockedInodePath)1 MergeJournalContext (alluxio.master.journal.MergeJournalContext)1 UpdateInodeEntry (alluxio.proto.journal.File.UpdateInodeEntry)1 LockResource (alluxio.resource.LockResource)1 Mode (alluxio.security.authorization.Mode)1