Search in sources :

Example 6 with OperationId

use of alluxio.wire.OperationId in project alluxio by Alluxio.

the class InodeTreePersistentState method applyAndJournal.

/**
 * Updates an inode's state. This is used for state common to both files and directories.
 *
 * @param context journal context supplier
 * @param entry update inode entry
 */
public void applyAndJournal(Supplier<JournalContext> context, UpdateInodeEntry entry) {
    try {
        applyUpdateInode(entry);
        JournalEntry.Builder builder = JournalEntry.newBuilder().setUpdateInode(entry);
        OperationId opId = getOpId(context);
        if (opId != null) {
            builder.setOperationId(opId.toJournalProto());
        }
        context.get().append(builder.build());
    } catch (Throwable t) {
        ProcessUtils.fatalError(LOG, t, "Failed to apply %s", entry);
        // fatalError will usually system.exit
        throw t;
    }
}
Also used : OperationId(alluxio.wire.OperationId) JournalEntry(alluxio.proto.journal.Journal.JournalEntry)

Example 7 with OperationId

use of alluxio.wire.OperationId in project alluxio by Alluxio.

the class FileSystemMasterFaultToleranceIntegrationTest method partitionTolerantDeleteDirectory.

@Test
public void partitionTolerantDeleteDirectory() throws Exception {
    // Create paths for the test.
    AlluxioURI testPath1 = new AlluxioURI("/testPath1");
    // Create context1 with unique operation id.
    DeleteContext context = DeleteContext.mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Create context2 with unique operation id.
    DeleteContext context2 = DeleteContext.mergeFrom(DeletePOptions.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 delete.
        leadingFsMaster.createDirectory(testPath1, CreateDirectoryContext.defaults());
        // Delete the path the first time.
        leadingFsMaster.delete(testPath1, context);
        // Delete the path the second time with the same context.
        // It should just return successfully.
        leadingFsMaster.delete(testPath1, context);
        // Delete the path again with a different context.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.delete(testPath1, 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);
        // Deleting the path on the new leader with the original operation-id should succeed.
        leadingFsMaster.delete(testPath1, context);
        // Deleting on the new leader with a different operation-id.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.delete(testPath1, context2));
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) DeleteContext(alluxio.master.file.contexts.DeleteContext) OperationId(alluxio.wire.OperationId) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 8 with OperationId

use of alluxio.wire.OperationId in project alluxio by Alluxio.

the class FileSystemMasterFaultToleranceIntegrationTest method partitionTolerantCompleteFile.

@Test
public void partitionTolerantCompleteFile() throws Exception {
    // Create paths for the test.
    AlluxioURI testPath1 = new AlluxioURI("/testPath1");
    // Create context1 with unique operation id.
    CompleteFileContext context = CompleteFileContext.mergeFrom(CompleteFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Create context2 with unique operation id.
    CompleteFileContext context2 = CompleteFileContext.mergeFrom(CompleteFilePOptions.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 complete.
        leadingFsMaster.createFile(testPath1, CreateFileContext.defaults());
        // Complete the path the first time.
        leadingFsMaster.completeFile(testPath1, context);
        // Complete the path the second time with the same context.
        // It should just return successfully.
        leadingFsMaster.completeFile(testPath1, context);
        // Complete the file again with a different context.
        // It should fail with `FileAlreadyCompletedException`.
        assertThrows(FileAlreadyCompletedException.class, () -> leadingFsMaster.completeFile(testPath1, 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);
        // Completing the file on the new leader with the original operation-id should succeed.
        leadingFsMaster.completeFile(testPath1, context);
        // Creating on the new leader with a different operation-id.
        // It should fail with `FileAlreadyCompletedException`.
        assertThrows(FileAlreadyCompletedException.class, () -> leadingFsMaster.completeFile(testPath1, context2));
    }
}
Also used : OperationId(alluxio.wire.OperationId) FileSystemMaster(alluxio.master.file.FileSystemMaster) CompleteFileContext(alluxio.master.file.contexts.CompleteFileContext) FileAlreadyCompletedException(alluxio.exception.FileAlreadyCompletedException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with OperationId

use of alluxio.wire.OperationId in project alluxio by Alluxio.

the class FileSystemMasterFaultToleranceIntegrationTest method partitionTolerantCreateFile.

@Test
public void partitionTolerantCreateFile() throws Exception {
    // Create paths for the test.
    AlluxioURI testPath1 = new AlluxioURI("/testPath1");
    // Create context1 with unique operation id.
    CreateFileContext context = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Create context2 with unique operation id.
    CreateFileContext context2 = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Run partition tolerance test on leading master.
    {
        // Acquire file-system-master of leading master.
        final FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Create the path the first time.
        leadingFsMaster.createFile(testPath1, context);
        // Create the path the second time with the same context.
        // It should just return successfully.
        FileInfo fileInfo = leadingFsMaster.createFile(testPath1, context);
        Assert.assertEquals(fileInfo.getFileId(), leadingFsMaster.getFileId(testPath1));
        // Create the file again with a different context.
        // It should fail with `FileAlreadyExistException`.
        assertThrows(FileAlreadyExistsException.class, () -> leadingFsMaster.createFile(testPath1, 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.
        final FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Creating on the new leader with the original operation-id should succeed.
        FileInfo fileInfo = leadingFsMaster.createFile(testPath1, context);
        Assert.assertEquals(fileInfo.getFileId(), leadingFsMaster.getFileId(testPath1));
        // Creating on the new leader with a different operation-id should fail.
        assertThrows(FileAlreadyExistsException.class, () -> leadingFsMaster.createFile(testPath1, context2));
    }
}
Also used : CreateFileContext(alluxio.master.file.contexts.CreateFileContext) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) FileInfo(alluxio.wire.FileInfo) OperationId(alluxio.wire.OperationId) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 10 with OperationId

use of alluxio.wire.OperationId 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

OperationId (alluxio.wire.OperationId)10 AlluxioURI (alluxio.AlluxioURI)5 FileSystemMaster (alluxio.master.file.FileSystemMaster)5 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)5 Test (org.junit.Test)5 JournalEntry (alluxio.proto.journal.Journal.JournalEntry)4 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 DeleteContext (alluxio.master.file.contexts.DeleteContext)2 BlockOutStream (alluxio.client.block.stream.BlockOutStream)1 FileAlreadyCompletedException (alluxio.exception.FileAlreadyCompletedException)1 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 CompleteFilePOptions (alluxio.grpc.CompleteFilePOptions)1 CompleteFileContext (alluxio.master.file.contexts.CompleteFileContext)1 CreateFileContext (alluxio.master.file.contexts.CreateFileContext)1 RenameContext (alluxio.master.file.contexts.RenameContext)1 FileInfo (alluxio.wire.FileInfo)1