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;
}
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;
}
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);
}
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());
}
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));
}
Aggregations