Search in sources :

Example 6 with FileSystemMaster

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

the class JournalIntegrationTest method failDuringCheckpointDelete.

@Test
public void failDuringCheckpointDelete() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    mFileSystem.createFile(file).close();
    // Restart the master once so that it creates a checkpoint file.
    mLocalAlluxioCluster.stopFS();
    createFsMasterFromJournal();
    AlluxioURI journal = new AlluxioURI(Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER));
    try (UnderFileSystemSpy ufsSpy = new UnderFileSystemSpy(journal)) {
        doThrow(new RuntimeException("Failed to delete")).when(ufsSpy.get()).deleteFile(Mockito.contains("FileSystemMaster/checkpoint.data"));
        try {
            // Restart the master again, but with deleting the checkpoint file failing.
            mLocalAlluxioCluster.stopFS();
            createFsMasterFromJournal();
            Assert.fail("Should have failed during delete");
        } catch (RuntimeException e) {
            Assert.assertEquals("Failed to delete", e.getMessage());
        }
    }
    // We shouldn't lose track of the fact that the file is loaded into memory.
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    Assert.assertTrue(fsMaster.getInMemoryFiles().contains(file));
}
Also used : UnderFileSystemSpy(alluxio.UnderFileSystemSpy) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 7 with FileSystemMaster

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

the class JournalIntegrationTest method manyFileTestUtil.

private void manyFileTestUtil() throws Exception {
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    long rootId = fsMaster.getFileId(mRootUri);
    Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
    Assert.assertEquals(10, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
    for (int k = 0; k < 10; k++) {
        Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/a" + k)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI)

Example 8 with FileSystemMaster

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

the class JournalShutdownIntegrationTest method reproduceAndCheckState.

/**
   * Reproduce the journal and check if the state is correct.
   */
private void reproduceAndCheckState(int successFiles) throws Exception {
    Assert.assertNotEquals(successFiles, 0);
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    int actualFiles = fsMaster.listStatus(new AlluxioURI(TEST_FILE_DIR), ListStatusOptions.defaults()).size();
    Assert.assertTrue((successFiles == actualFiles) || (successFiles + 1 == actualFiles));
    for (int f = 0; f < successFiles; f++) {
        Assert.assertTrue(fsMaster.getFileId(new AlluxioURI(TEST_FILE_DIR + f)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI)

Example 9 with FileSystemMaster

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

the class JournalIntegrationTest method mountEntryCheckpointTest.

/**
   * Tests the situation where a checkpoint mount entry is replayed by a standby master.
   *
   * @throws Exception on error
   */
@Test
public void mountEntryCheckpointTest() throws Exception {
    final AlluxioURI mountUri = new AlluxioURI("/local_mnt/");
    final AlluxioURI ufsUri = new AlluxioURI(mTestFolder.newFolder("test_ufs").getAbsolutePath());
    // Create a mount point, which will journal a mount entry.
    mFileSystem.mount(mountUri, ufsUri);
    mLocalAlluxioCluster.stopFS();
    // Start a leader master, which will create a new checkpoint, with a mount entry.
    MasterTestUtils.createLeaderFileSystemMasterFromJournal().stop();
    // Start a standby master, which will replay the mount entry from the checkpoint.
    final FileSystemMaster fsMaster = MasterTestUtils.createStandbyFileSystemMasterFromJournal();
    try {
        CommonUtils.waitFor("standby journal checkpoint replay", new Function<Void, Boolean>() {

            @Override
            public Boolean apply(Void input) {
                try {
                    fsMaster.listStatus(mountUri, ListStatusOptions.defaults());
                    return true;
                } catch (Exception e) {
                    return false;
                }
            }
        }, WaitForOptions.defaults().setTimeout(60 * Constants.SECOND_MS));
    } finally {
        fsMaster.stop();
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) InvalidPathException(alluxio.exception.InvalidPathException) IOException(java.io.IOException) AccessControlException(alluxio.exception.AccessControlException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 10 with FileSystemMaster

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

the class JournalIntegrationTest method multiEditLogTestUtil.

private void multiEditLogTestUtil() throws Exception {
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    long rootId = fsMaster.getFileId(mRootUri);
    Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
    Assert.assertEquals(124, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
    for (int k = 0; k < 124; k++) {
        Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/a" + k)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI)

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