Class RaftStorage
java.lang.Object
org.opendaylight.controller.cluster.raft.spi.RaftStorage
- All Implemented Interfaces:
EntryStore
,SnapshotStore
- Direct Known Subclasses:
DisabledRaftStorage
,EnabledRaftStorage
public abstract sealed class RaftStorage
extends Object
implements EntryStore, SnapshotStore
permits DisabledRaftStorage, EnabledRaftStorage
Internal interface towards storage entities.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull RaftStorageCompleter
protected final @NonNull CompressionType
protected final @NonNull Path
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RaftStorage
(RaftStorageCompleter completer, Path directory, CompressionType compression, FileBackedOutputStream.Configuration streamConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected MoreObjects.ToStringHelper
final @NonNull RaftStorageCompleter
Returns theRaftStorageCompleter
.final @Nullable SnapshotFile
Returns the last available snapshot.protected final String
memberId()
protected abstract void
protected abstract void
preStop()
void
saveSnapshot
(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, Instant timestamp) Saves a snapshot synchronously and delete any previous snapshots.final void
saveSnapshot
(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, RaftCallback<Instant> callback) Saves a snapshot asynchronously and delete any previous snapshots.final void
start()
final void
stop()
final void
streamToInstall
(EntryInfo lastIncluded, StateSnapshot.ToStorage<?> snapshot, RaftCallback<InstallableSnapshot> callback) Serialize aStateSnapshot.ToStorage
snapshot and make the result available as anInstallableSnapshot
to the specified callback.protected final void
submitTask
(@NonNull RaftStorage.CancellableTask<?> task) final String
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
checkpointLastApplied, discardHead, discardTail, persistEntry, startPersistEntry
-
Field Details
-
completer
-
compression
-
directory
-
-
Constructor Details
-
RaftStorage
protected RaftStorage(RaftStorageCompleter completer, Path directory, CompressionType compression, FileBackedOutputStream.Configuration streamConfig)
-
-
Method Details
-
memberId
-
start
- Throws:
IOException
-
postStart
- Throws:
IOException
-
stop
public final void stop() -
preStop
protected abstract void preStop() -
completer
Description copied from interface:EntryStore
Returns theRaftStorageCompleter
.- Specified by:
completer
in interfaceEntryStore
- Returns:
- the
RaftStorageCompleter
-
lastSnapshot
Description copied from interface:SnapshotStore
Returns the last available snapshot.- Specified by:
lastSnapshot
in interfaceSnapshotStore
- Returns:
- the last available snapshot
- Throws:
IOException
- if an I/O error occurs
-
streamToInstall
@NonNullByDefault public final void streamToInstall(EntryInfo lastIncluded, StateSnapshot.ToStorage<?> snapshot, RaftCallback<InstallableSnapshot> callback) Description copied from interface:SnapshotStore
Serialize aStateSnapshot.ToStorage
snapshot and make the result available as anInstallableSnapshot
to the specified callback.- Specified by:
streamToInstall
in interfaceSnapshotStore
- Parameters:
lastIncluded
- last included index/termsnapshot
- the snapshotcallback
- the callback to invoke
-
saveSnapshot
public final void saveSnapshot(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, RaftCallback<Instant> callback) Description copied from interface:SnapshotStore
Saves a snapshot asynchronously and delete any previous snapshots.- Specified by:
saveSnapshot
in interfaceSnapshotStore
- Parameters:
raftSnapshot
- theRaftSnapshot
, receiving the snapshot timestamplastIncluded
- last included index/termsnapshot
- the snapshot, ornull
if not applicablecallback
- the callback to invoke
-
saveSnapshot
public void saveSnapshot(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, Instant timestamp) throws IOException Description copied from interface:SnapshotStore
Saves a snapshot synchronously and delete any previous snapshots. This method should only be called during recovery.- Specified by:
saveSnapshot
in interfaceSnapshotStore
- Parameters:
raftSnapshot
- theRaftSnapshot
lastIncluded
- last included index/termsnapshot
- the snapshot, ornull
if not applicabletimestamp
- snapshot timestamp- Throws:
IOException
- when an I/O error occurs
-
submitTask
-
toString
-
addToStringAtrributes
-