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