use of io.atomix.protocols.raft.storage.log.entry.OpenSessionEntry in project atomix by atomix.
the class RaftServiceManagerTest method testInstallSnapshotOnApply.
@Test
public void testInstallSnapshotOnApply() throws Exception {
RaftLogWriter writer = raft.getLogWriter();
writer.append(new InitializeEntry(1, System.currentTimeMillis()));
writer.append(new OpenSessionEntry(1, System.currentTimeMillis(), "test-1", "test", "test", null, ReadConsistency.LINEARIZABLE, 100, 1000));
writer.commit(2);
RaftServiceManager manager = raft.getServiceManager();
manager.apply(2).join();
Snapshot snapshot = manager.snapshot();
assertEquals(2, snapshot.index());
assertTrue(snapshotTaken.get());
snapshot.complete();
assertEquals(2, raft.getSnapshotStore().getCurrentSnapshot().index());
writer.append(new CommandEntry(1, System.currentTimeMillis(), 2, 1, new PrimitiveOperation(RUN, new byte[0])));
writer.commit(3);
manager.apply(3).join();
assertTrue(snapshotInstalled.get());
}
use of io.atomix.protocols.raft.storage.log.entry.OpenSessionEntry in project atomix by atomix.
the class RaftServiceManagerTest method testSnapshotTakeInstall.
@Test
public void testSnapshotTakeInstall() throws Exception {
RaftLogWriter writer = raft.getLogWriter();
writer.append(new InitializeEntry(1, System.currentTimeMillis()));
writer.append(new OpenSessionEntry(1, System.currentTimeMillis(), "test-1", "test", "test", null, ReadConsistency.LINEARIZABLE, 100, 1000));
writer.commit(2);
RaftServiceManager manager = raft.getServiceManager();
manager.apply(2).join();
Snapshot snapshot = manager.snapshot();
assertEquals(2, snapshot.index());
assertTrue(snapshotTaken.get());
snapshot = snapshot.complete();
assertEquals(2, raft.getSnapshotStore().getCurrentSnapshot().index());
manager.install(snapshot);
assertTrue(snapshotInstalled.get());
}
Aggregations