Interface EntryStore
- All Known Subinterfaces:
ImmediateEntryStore
- All Known Implementing Classes:
DisabledRaftStorage
,EnabledRaftStorage
,ForwardingEntryStore
,RaftStorage
@NonNullByDefault
public interface EntryStore
Interface to a access and manage
StateMachineCommand
-bearing entries with EntryMeta
. This interface
is inherently asynchronous, with the assumption that each request is enqueued to a background thread, which processes
requests in batches. Synchronization with the enclosing RaftActor
is either asynchronous
(via RaftCallback
s), or defined to terminate the actor on failure.-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkpointLastApplied
(long commitJournalIndex) Record a known value oflastApplied
as a recovery optimization.Returns theRaftStorageCompleter
.void
discardHead
(long firstRetainedIndex) Deletes journal entries up to, but not including, the givenjournalIndex
.void
discardTail
(long firstRemovedIndex) Delete entries starting from, and including, specified index.default void
persistEntry
(ReplicatedLogEntry entry, RaftCallback<Long> callback) Persists an entry to the applicable journal synchronously.void
startPersistEntry
(ReplicatedLogEntry entry, RaftCallback<Long> callback) Persists an entry to the applicable journal asynchronously.
-
Method Details
-
completer
RaftStorageCompleter completer()Returns theRaftStorageCompleter
.- Returns:
- the
RaftStorageCompleter
-
persistEntry
Persists an entry to the applicable journal synchronously. The contract is that the callback will be invoked beforeRaftActor
sees any other message. Default implementation registers the callback withcompleter()
and defers tostartPersistEntry(ReplicatedLogEntry, RaftCallback)
.- Parameters:
entry
- the journal entry to persistcallback
- the callback when persistence is complete
-
startPersistEntry
Persists an entry to the applicable journal asynchronously.- Parameters:
entry
- the journal entry to persistcallback
- the callback when persistence is complete
-
discardHead
void discardHead(long firstRetainedIndex) Deletes journal entries up to, but not including, the givenjournalIndex
.- Parameters:
firstRetainedIndex
- thejournalIndex
of the first retained entry
-
discardTail
void discardTail(long firstRemovedIndex) Delete entries starting from, and including, specified index. The contract is that the callback will be invoked beforeRaftActor
sees any other message.- Parameters:
firstRemovedIndex
- thejournalIndex
of first entry to delete
-
checkpointLastApplied
void checkpointLastApplied(long commitJournalIndex) Record a known value oflastApplied
as a recovery optimization. If we can recover this information, recovery can re-apply these entries before we attempt to talk to other members. It is okay to lose this marker, as in that case we will just apply those entries as part of being a follower or becoming a leader.This amounts to persisting a lower bound on
commitIndex
, which is explicitly volatile state. We could remember that instead (or perhaps as well) -- but now we just derive it.If we later discover that this index lies beyond current leader's
commitIndex
, we will ask for a complete snapshot -- which is not particularly nice, but should happen seldom enough for it not to matter much.- Parameters:
commitJournalIndex
-the journalIndex
of the entry which is covered bycommitIndex
and has been observed aslastApplied
.
-