use of alluxio.master.NoopMaster in project alluxio by Alluxio.
the class UfsJournalCheckpointThreadTest method before.
@Before
public void before() throws Exception {
URI location = URIUtils.appendPathOrDie(new URI(mFolder.newFolder().getAbsolutePath()), "FileSystemMaster");
mUfs = Mockito.spy(UnderFileSystem.Factory.create(location.toString(), ServerConfiguration.global()));
mJournal = new UfsJournal(location, new NoopMaster(), mUfs, 600, Collections::emptySet);
mJournal.start();
mJournal.gainPrimacy();
}
use of alluxio.master.NoopMaster in project alluxio by Alluxio.
the class RaftJournalTest method catchUpInSteps.
// Raft journal receives leader knowledge in chunks.
// So advancing should take into account seeing partial knowledge.
@Test
public void catchUpInSteps() throws Exception {
// Create a counting master implementation that counts how many journal entries it processed.
CountingDummyFileSystemMaster countingMaster = new CountingDummyFileSystemMaster();
mFollowerJournalSystem.createJournal(countingMaster);
// Suspend follower journal system.
mFollowerJournalSystem.suspend(null);
final int entryBatchCount = 5;
// Create batch of entries on the leader journal context.
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
for (int i = 0; i < entryBatchCount; i++) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(i).build()).build());
}
}
// Catch up follower journal system to target-index:(fileCount * 2) - 1.
Map<String, Long> backupSequences = new HashMap<>();
backupSequences.put("FileSystemMaster", (long) (entryBatchCount * 2) - 1);
CatchupFuture catchupFuture = mFollowerJournalSystem.catchup(backupSequences);
// Create next batch of entries on the leader journal context.
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
for (int i = 0; i < entryBatchCount; i++) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(i).build()).build());
}
}
// Wait for sequence to be caught up.
catchupFuture.waitTermination();
Assert.assertEquals(entryBatchCount * 2, countingMaster.getApplyCount());
// Catchup on the already met sequence.
mFollowerJournalSystem.catchup(backupSequences);
Assert.assertEquals(entryBatchCount * 2, countingMaster.getApplyCount());
}
use of alluxio.master.NoopMaster in project alluxio by Alluxio.
the class RaftJournalTest method suspendCatchupResume.
@Test
public void suspendCatchupResume() throws Exception {
// Create a counting master implementation that counts how many journal entries it processed.
CountingDummyFileSystemMaster countingMaster = new CountingDummyFileSystemMaster();
mFollowerJournalSystem.createJournal(countingMaster);
// Suspend follower journal system.
mFollowerJournalSystem.suspend(null);
try {
mFollowerJournalSystem.suspend(null);
Assert.fail("Suspend succeeded for already suspended journal.");
} catch (Exception e) {
// Expected to fail when suspending a suspended journal.
}
// Catch up follower journal system to target-index:5.
final long catchupIndex = 5;
Map<String, Long> backupSequences = new HashMap<>();
backupSequences.put("FileSystemMaster", catchupIndex);
CatchupFuture catchupFuture = mFollowerJournalSystem.catchup(backupSequences);
// Create entries on the leader journal context.
// These will be replicated to follower journal context.
final int entryCount = 10;
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
for (int i = 0; i < entryCount; i++) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(i).build()).build());
}
}
// Wait for sequences to be caught up.
catchupFuture.waitTermination();
Assert.assertEquals(catchupIndex + 1, countingMaster.getApplyCount());
// Wait for election timeout and verify follower master state hasn't changed.
Thread.sleep(ServerConfiguration.getMs(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT));
Assert.assertEquals(catchupIndex + 1, countingMaster.getApplyCount());
// Exit backup mode and wait until follower master acquires the current knowledge.
mFollowerJournalSystem.resume();
CommonUtils.waitFor("full state acquired", () -> countingMaster.getApplyCount() == entryCount, mWaitOptions);
// Write more entries and validate they are replicated to follower.
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(entryCount).build()).build());
}
CommonUtils.waitFor("full state acquired after resume", () -> countingMaster.getApplyCount() == entryCount + 1, mWaitOptions);
}
use of alluxio.master.NoopMaster in project alluxio by Alluxio.
the class RaftJournalTest method joinCluster.
@Test
public void joinCluster() throws Exception {
// Create entries on the leader journal context.
// These will be replicated to follower journal context.
final int entryCount = 10;
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
for (int i = 0; i < entryCount; i++) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(i).build()).build());
}
}
RaftJournalSystem newJs = createNewJournalSystem(mLeaderJournalSystem);
// Create a counting master implementation that counts how many journal entries it processed.
CountingDummyFileSystemMaster countingMaster = new CountingDummyFileSystemMaster();
newJs.createJournal(countingMaster);
newJs.start();
// Write more entries and validate they are replicated to follower.
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(entryCount).build()).build());
}
CommonUtils.waitFor("follower catches up on all changes", () -> countingMaster.getApplyCount() == entryCount + 1, mWaitOptions);
}
use of alluxio.master.NoopMaster in project alluxio by Alluxio.
the class RaftJournalTest method writeJournal.
@Test
public void writeJournal() throws Exception {
// Create a counting master implementation that counts how many journal entries it processed.
CountingDummyFileSystemMaster countingMaster = new CountingDummyFileSystemMaster();
mFollowerJournalSystem.createJournal(countingMaster);
// Create entries on the leader journal context.
// These will be replicated to follower journal context.
final int entryCount = 10;
try (JournalContext journalContext = mLeaderJournalSystem.createJournal(new NoopMaster()).createJournalContext()) {
for (int i = 0; i < entryCount; i++) {
journalContext.append(alluxio.proto.journal.Journal.JournalEntry.newBuilder().setInodeLastModificationTime(File.InodeLastModificationTimeEntry.newBuilder().setId(i).build()).build());
}
}
// Wait for sequences to be caught up.
CommonUtils.waitFor("full state acquired", () -> countingMaster.getApplyCount() == entryCount, mWaitOptions);
}
Aggregations