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 RaftStorageCompleterprotected final @NonNull CompressionTypeprotected final @NonNull Path -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRaftStorage(RaftStorageCompleter completer, Path directory, CompressionType compression, FileBackedOutputStream.Configuration streamConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected MoreObjects.ToStringHelperfinal @NonNull RaftStorageCompleterReturns theRaftStorageCompleter.final @Nullable SnapshotFileReturns the last available snapshot.protected final StringmemberId()protected abstract voidprotected abstract voidpreStop()static final voidsaveSnapshot(String memberId, Path directory, SnapshotFileFormat format, CompressionType compression, RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, Instant timestamp) voidsaveSnapshot(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, Instant timestamp) Saves a snapshot synchronously and delete any previous snapshots.final voidsaveSnapshot(RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, RaftCallback<Instant> callback) Saves a snapshot asynchronously and delete any previous snapshots.final voidstart()final voidstop()final voidstreamToInstall(EntryInfo lastIncluded, StateSnapshot.ToStorage<?> snapshot, RaftCallback<InstallableSnapshot> callback) Serialize aStateSnapshot.ToStoragesnapshot and make the result available as anInstallableSnapshotto the specified callback.protected final voidsubmitTask(@NonNull RaftStorage.CancellableTask<?> task) final StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:EntryStoreReturns theRaftStorageCompleter.- Specified by:
completerin interfaceEntryStore- Returns:
- the
RaftStorageCompleter
-
lastSnapshot
Description copied from interface:SnapshotStoreReturns the last available snapshot.- Specified by:
lastSnapshotin 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:SnapshotStoreSerialize aStateSnapshot.ToStoragesnapshot and make the result available as anInstallableSnapshotto the specified callback.- Specified by:
streamToInstallin 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:SnapshotStoreSaves a snapshot asynchronously and delete any previous snapshots.- Specified by:
saveSnapshotin interfaceSnapshotStore- Parameters:
raftSnapshot- theRaftSnapshot, receiving the snapshot timestamplastIncluded- last included index/termsnapshot- the snapshot, ornullif 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:SnapshotStoreSaves a snapshot synchronously and delete any previous snapshots. This method should only be called during recovery.- Specified by:
saveSnapshotin interfaceSnapshotStore- Parameters:
raftSnapshot- theRaftSnapshotlastIncluded- last included index/termsnapshot- the snapshot, ornullif not applicabletimestamp- snapshot timestamp- Throws:
IOException- when an I/O error occurs
-
saveSnapshot
@NonNullByDefault public static final void saveSnapshot(String memberId, Path directory, SnapshotFileFormat format, CompressionType compression, RaftSnapshot raftSnapshot, EntryInfo lastIncluded, @Nullable StateSnapshot.ToStorage<?> snapshot, Instant timestamp) throws IOException - Throws:
IOException
-
submitTask
-
toString
-
addToStringAtrributes
-