public class RaftStorage extends Object
RaftLog factory.
This class provides a factory for RaftLog objects. Storage objects are immutable and
can be created only via the RaftStorage.Builder. To create a new
Storage.Builder, use the static newBuilder() factory method:
Storage storage = Storage.builder()
.withDirectory(new File("logs"))
.withStorageLevel(StorageLevel.DISK)
.build();
RaftLog| Modifier and Type | Class and Description |
|---|---|
static class |
RaftStorage.Builder
Builds a
RaftStorage configuration. |
| Modifier and Type | Method and Description |
|---|---|
void |
deleteLog()
Deletes a
RaftLog from disk. |
void |
deleteMetaStore()
Deletes a
MetaStore from disk. |
void |
deleteSnapshotStore()
Deletes a
SnapshotStore from disk. |
File |
directory()
Returns the storage directory.
|
boolean |
dynamicCompaction()
Returns whether dynamic log compaction is enabled.
|
double |
freeDiskBuffer()
Returns the percentage of disk space that must be available before log compaction is forced.
|
boolean |
isFlushOnCommit()
Returns whether to flush buffers to disk when entries are committed.
|
boolean |
isRetainStaleSnapshots()
Returns a boolean value indicating whether to retain stale snapshots on disk.
|
int |
maxLogEntriesPerSegment()
Returns the maximum number of entries per segment.
|
int |
maxLogSegmentSize()
Returns the maximum log segment size.
|
static RaftStorage.Builder |
newBuilder()
Returns a new storage builder.
|
RaftLog |
openLog()
Opens a new
RaftLog, recovering the log from disk if it exists. |
MetaStore |
openMetaStore()
Opens a new
MetaStore, recovering metadata from disk if it exists. |
SnapshotStore |
openSnapshotStore()
Opens a new
SnapshotStore, recovering snapshots from disk if they exist. |
String |
prefix()
Returns the storage filename prefix.
|
io.atomix.serializer.Serializer |
serializer()
Returns the storage serializer.
|
io.atomix.storage.statistics.StorageStatistics |
statistics()
Returns the Raft storage statistics.
|
io.atomix.storage.StorageLevel |
storageLevel()
Returns the storage level.
|
String |
toString() |
public static RaftStorage.Builder newBuilder()
public String prefix()
public io.atomix.serializer.Serializer serializer()
public File directory()
The storage directory is the directory to which all RaftLogs write files. Segment files
for multiple logs may be stored in the storage directory, and files for each log instance will be identified
by the name provided when the log is opened.
public io.atomix.storage.StorageLevel storageLevel()
The storage level dictates how entries within individual log RaftLogs should be stored.
public int maxLogSegmentSize()
The maximum segment size dictates the maximum size any segment in a RaftLog may consume
in bytes.
public int maxLogEntriesPerSegment()
The maximum entries per segment dictates the maximum number of entries
that are allowed to be stored in any segment in a RaftLog.
public boolean dynamicCompaction()
public double freeDiskBuffer()
public boolean isFlushOnCommit()
public boolean isRetainStaleSnapshots()
If this option is enabled, snapshots will be retained on disk even after they no longer contribute to the state of the system (there's a more recent snapshot). Users may want to disable this option for backup purposes.
public io.atomix.storage.statistics.StorageStatistics statistics()
public MetaStore openMetaStore()
MetaStore, recovering metadata from disk if it exists.
The meta store will be loaded using based on the configured StorageLevel. If the storage level is persistent
then the meta store will be loaded from disk, otherwise a new meta store will be created.
public void deleteMetaStore()
MetaStore from disk.
The meta store will be deleted by simply reading meta file names from disk and deleting metadata
files directly. Deleting the meta store does not involve reading any metadata files into memory.
public SnapshotStore openSnapshotStore()
SnapshotStore, recovering snapshots from disk if they exist.
The snapshot store will be loaded using based on the configured StorageLevel. If the storage level is persistent
then the snapshot store will be loaded from disk, otherwise a new snapshot store will be created.
public void deleteSnapshotStore()
SnapshotStore from disk.
The snapshot store will be deleted by simply reading snapshot file names from disk and deleting snapshot
files directly. Deleting the snapshot store does not involve reading any snapshot files into memory.
public RaftLog openLog()
RaftLog, recovering the log from disk if it exists.
When a log is opened, the log will attempt to load segments from the storage directory()
according to the provided log name. If segments for the given log name are present on disk, segments
will be loaded and indexes will be rebuilt from disk. If no segments are found, an empty log will be created.
When log files are loaded from disk, the file names are expected to be based on the provided log name.
public void deleteLog()
RaftLog from disk.
The log will be deleted by simply reading log file names from disk and deleting log files directly.
Deleting log files does not involve rebuilding indexes or reading any logs into memory.
Copyright © 2013–2017. All rights reserved.