Class EnabledRaftStorage
java.lang.Object
org.opendaylight.controller.cluster.raft.spi.RaftStorage
org.opendaylight.controller.cluster.raft.spi.EnabledRaftStorage
- All Implemented Interfaces:
EntryStore
,SnapshotStore
A
RaftStorage
backing persistent mode of RaftActor
operation.-
Nested Class Summary
Nested classes/interfaces inherited from class org.opendaylight.controller.cluster.raft.spi.RaftStorage
RaftStorage.CancellableTask<T>
-
Field Summary
Fields inherited from class org.opendaylight.controller.cluster.raft.spi.RaftStorage
completer, compression, directory
-
Constructor Summary
ConstructorsConstructorDescriptionEnabledRaftStorage
(RaftStorageCompleter completer, Path directory, CompressionType compression, FileBackedOutputStream.Configuration streamConfig, boolean mapped) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkpointLastApplied
(long commitJournalIndex) Record a known value oflastApplied
as a recovery optimization.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.journal()
Returns the underlying EntryJournal.protected void
protected void
preStop()
void
startPersistEntry
(ReplicatedLogEntry entry, RaftCallback<Long> callback) Persists an entry to the applicable journal asynchronously.Methods inherited from class org.opendaylight.controller.cluster.raft.spi.RaftStorage
addToStringAtrributes, completer, lastSnapshot, memberId, saveSnapshot, saveSnapshot, start, stop, streamToInstall, submitTask, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opendaylight.controller.cluster.raft.spi.EntryStore
persistEntry
-
Constructor Details
-
EnabledRaftStorage
@NonNullByDefault public EnabledRaftStorage(RaftStorageCompleter completer, Path directory, CompressionType compression, FileBackedOutputStream.Configuration streamConfig, boolean mapped)
-
-
Method Details
-
journal
Returns the underlying EntryJournal.- Returns:
- the underlying EntryJournal
-
startPersistEntry
@NonNullByDefault public void startPersistEntry(ReplicatedLogEntry entry, RaftCallback<Long> callback) Description copied from interface:EntryStore
Persists an entry to the applicable journal asynchronously.- Parameters:
entry
- the journal entry to persistcallback
- the callback when persistence is complete
-
discardHead
public void discardHead(long firstRetainedIndex) Description copied from interface:EntryStore
Deletes journal entries up to, but not including, the givenjournalIndex
.- Parameters:
firstRetainedIndex
- thejournalIndex
of the first retained entry
-
discardTail
public void discardTail(long firstRemovedIndex) Description copied from interface:EntryStore
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
public void checkpointLastApplied(long commitJournalIndex) Description copied from interface:EntryStore
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
.
-
postStart
- Specified by:
postStart
in classRaftStorage
- Throws:
IOException
-
preStop
protected void preStop()- Specified by:
preStop
in classRaftStorage
-