Search in sources :

Example 1 with OpenSessionEntry

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());
}
Also used : PrimitiveOperation(io.atomix.primitive.operation.PrimitiveOperation) Snapshot(io.atomix.protocols.raft.storage.snapshot.Snapshot) CommandEntry(io.atomix.protocols.raft.storage.log.entry.CommandEntry) OpenSessionEntry(io.atomix.protocols.raft.storage.log.entry.OpenSessionEntry) InitializeEntry(io.atomix.protocols.raft.storage.log.entry.InitializeEntry) RaftLogWriter(io.atomix.protocols.raft.storage.log.RaftLogWriter) Test(org.junit.Test)

Example 2 with OpenSessionEntry

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());
}
Also used : Snapshot(io.atomix.protocols.raft.storage.snapshot.Snapshot) OpenSessionEntry(io.atomix.protocols.raft.storage.log.entry.OpenSessionEntry) InitializeEntry(io.atomix.protocols.raft.storage.log.entry.InitializeEntry) RaftLogWriter(io.atomix.protocols.raft.storage.log.RaftLogWriter) Test(org.junit.Test)

Aggregations

RaftLogWriter (io.atomix.protocols.raft.storage.log.RaftLogWriter)2 InitializeEntry (io.atomix.protocols.raft.storage.log.entry.InitializeEntry)2 OpenSessionEntry (io.atomix.protocols.raft.storage.log.entry.OpenSessionEntry)2 Snapshot (io.atomix.protocols.raft.storage.snapshot.Snapshot)2 Test (org.junit.Test)2 PrimitiveOperation (io.atomix.primitive.operation.PrimitiveOperation)1 CommandEntry (io.atomix.protocols.raft.storage.log.entry.CommandEntry)1