Search in sources :

Example 61 with FileSystemMaster

use of alluxio.master.file.FileSystemMaster in project alluxio by Alluxio.

the class FileSystemMasterFaultToleranceIntegrationTest method partitionTolerantRename.

@Test
public void partitionTolerantRename() throws Exception {
    // Create paths for the test.
    AlluxioURI testPath1 = new AlluxioURI("/testPath1");
    AlluxioURI testPath2 = new AlluxioURI("/testPath2");
    // Create context1 with unique operation id.
    RenameContext context = RenameContext.mergeFrom(RenamePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Create context2 with unique operation id.
    RenameContext context2 = RenameContext.mergeFrom(RenamePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Run partition tolerance test on leading master.
    {
        // Acquire file-system-master of leading master.
        FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Create the path to rename.
        leadingFsMaster.createDirectory(testPath1, CreateDirectoryContext.defaults());
        // Rename the path the first time.
        leadingFsMaster.rename(testPath1, testPath2, context);
        // Renaming the path the second time with the same context.
        // It should just return successfully.
        leadingFsMaster.rename(testPath1, testPath2, context);
        // Rename the path again with a different context.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.rename(testPath1, testPath2, context2));
    }
    // Promote standby to be a leader and reset test state.
    mMultiMasterLocalAlluxioCluster.stopLeader();
    mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS);
    mAuthenticatedUser.resetUser();
    // Run partition tolerance test on the *new* leading master.
    {
        // Acquire file-system-master of leading master.
        FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Renaming the path on the new leader with the original operation-id should succeed.
        leadingFsMaster.rename(testPath1, testPath2, context);
        // Renaming on the new leader with a different operation-id.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.rename(testPath1, testPath2, context2));
    }
}
Also used : RenameContext(alluxio.master.file.contexts.RenameContext) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) OperationId(alluxio.wire.OperationId) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

FileSystemMaster (alluxio.master.file.FileSystemMaster)61 AlluxioURI (alluxio.AlluxioURI)43 Test (org.junit.Test)27 FsMasterResource (alluxio.testutils.master.FsMasterResource)22 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)16 FileInfo (alluxio.wire.FileInfo)13 URIStatus (alluxio.client.file.URIStatus)10 OperationId (alluxio.wire.OperationId)5 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)4 UnderFileSystemSpy (alluxio.UnderFileSystemSpy)3 BlockMaster (alluxio.master.block.BlockMaster)3 MountPointInfo (alluxio.wire.MountPointInfo)3 FileSystem (alluxio.client.file.FileSystem)2 AccessControlException (alluxio.exception.AccessControlException)2 DefaultFileSystemMaster (alluxio.master.file.DefaultFileSystemMaster)2 PersistJob (alluxio.master.file.PersistJob)2 DeleteContext (alluxio.master.file.contexts.DeleteContext)2 JournalFactory (alluxio.master.journal.JournalFactory)2 Mode (alluxio.security.authorization.Mode)2 ExponentialTimer (alluxio.time.ExponentialTimer)2