Search in sources :

Example 1 with FileSystemMaster

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

the class MasterTestUtils method createLeaderFileSystemMasterFromJournal.

/**
   * Creates a new {@link FileSystemMaster} from journal.
   *
   * @return a new FileSystemMaster
   * @throws IOException
   */
public static FileSystemMaster createLeaderFileSystemMasterFromJournal() throws IOException {
    String masterJournal = Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER);
    JournalFactory journalFactory = new JournalFactory.ReadWrite(masterJournal);
    BlockMaster blockMaster = new BlockMaster(journalFactory);
    FileSystemMaster fsMaster = new FileSystemMaster(blockMaster, journalFactory);
    blockMaster.start(true);
    fsMaster.start(true);
    return fsMaster;
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) FileSystemMaster(alluxio.master.file.FileSystemMaster)

Example 2 with FileSystemMaster

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

the class MasterTestUtils method createStandbyFileSystemMasterFromJournal.

/**
   * Creates a new standby {@link FileSystemMaster} from journal.
   *
   * @return a new FileSystemMaster
   * @throws IOException
   */
public static FileSystemMaster createStandbyFileSystemMasterFromJournal() throws IOException {
    String masterJournal = Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER);
    JournalFactory journalFactory = new JournalFactory.ReadWrite(masterJournal);
    BlockMaster blockMaster = new BlockMaster(journalFactory);
    FileSystemMaster fsMaster = new FileSystemMaster(blockMaster, journalFactory);
    blockMaster.start(false);
    fsMaster.start(false);
    return fsMaster;
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) FileSystemMaster(alluxio.master.file.FileSystemMaster)

Example 3 with FileSystemMaster

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

the class StartupConsistencyCheckTest method inconsistent.

/**
   * Tests that an inconsistent Alluxio system's startup check correctly detects the inconsistent
   * files.
   */
@Test
public void inconsistent() throws Exception {
    String topLevelFileUfsPath = mFileSystem.getStatus(TOP_LEVEL_FILE).getUfsPath();
    String secondLevelDirUfsPath = mFileSystem.getStatus(SECOND_LEVEL_DIR).getUfsPath();
    mCluster.stopFS();
    UnderFileSystem ufs = UnderFileSystem.Factory.get(topLevelFileUfsPath);
    ufs.deleteFile(topLevelFileUfsPath);
    ufs.deleteDirectory(secondLevelDirUfsPath, DeleteOptions.defaults().setRecursive(true));
    final FileSystemMaster master = MasterTestUtils.createLeaderFileSystemMasterFromJournal();
    MasterTestUtils.waitForStartupConsistencyCheck(master);
    List expected = Lists.newArrayList(TOP_LEVEL_FILE, SECOND_LEVEL_DIR, THIRD_LEVEL_FILE);
    List result = master.getStartupConsistencyCheck().getInconsistentUris();
    Collections.sort(expected);
    Collections.sort(result);
    Assert.assertEquals(expected, result);
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) List(java.util.List) UnderFileSystem(alluxio.underfs.UnderFileSystem) Test(org.junit.Test)

Example 4 with FileSystemMaster

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

the class StartupConsistencyCheckTest method consistent.

/**
   * Tests that a consistent Alluxio system's startup check does not detect any inconsistencies
   * and completes within 1 minute.
   */
@Test
public void consistent() throws Exception {
    mCluster.stopFS();
    final FileSystemMaster master = MasterTestUtils.createLeaderFileSystemMasterFromJournal();
    MasterTestUtils.waitForStartupConsistencyCheck(master);
    Assert.assertTrue(master.getStartupConsistencyCheck().getInconsistentUris().isEmpty());
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) Test(org.junit.Test)

Example 5 with FileSystemMaster

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

the class JournalIntegrationTest method failDuringCheckpointRename.

@Test
public void failDuringCheckpointRename() 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 rename")).when(ufsSpy.get()).renameFile(Mockito.contains("FileSystemMaster/checkpoint.data.tmp"), anyString());
        try {
            // Restart the master again, but with renaming the checkpoint file failing.
            mLocalAlluxioCluster.stopFS();
            createFsMasterFromJournal();
            Assert.fail("Should have failed during rename");
        } catch (RuntimeException e) {
            Assert.assertEquals("Failed to rename", 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)

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