io.atomix.protocols.raft.storage.log.entry.InitializeEntry Java Examples
The following examples show how to use
io.atomix.protocols.raft.storage.log.entry.InitializeEntry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RaftServiceManager.java From atomix with Apache License 2.0 | 5 votes |
/** * Applies an initialize entry. * <p> * Initialize entries are used only at the beginning of a new leader's term to force the commitment of entries from * prior terms, therefore no logic needs to take place. */ private CompletableFuture<Void> applyInitialize(Indexed<InitializeEntry> entry) { for (RaftServiceContext service : raft.getServices()) { service.keepAliveSessions(entry.index(), entry.entry().timestamp()); } return CompletableFuture.completedFuture(null); }
Example #2
Source File: RaftServiceManagerTest.java From atomix with Apache License 2.0 | 5 votes |
@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()); }
Example #3
Source File: RaftServiceManagerTest.java From atomix with Apache License 2.0 | 5 votes |
@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()); }
Example #4
Source File: LeaderRole.java From atomix with Apache License 2.0 | 4 votes |
/** * Appends initial entries to the log to take leadership. */ private CompletableFuture<Void> appendInitialEntries() { final long term = raft.getTerm(); return appendAndCompact(new InitializeEntry(term, appender.getTime())).thenApply(index -> null); }