Package org.jgroups.raft.filelog
Class MetadataStorage
java.lang.Object
org.jgroups.raft.filelog.MetadataStorage
Stores the RAFT log metadata in a file.
The metadata includes the commit index, the current term and the last vote. The storage format keeps the fixed-size elements first and the vote last. The format follows:
+----------------+--------------+------------------+
| | | |
| COMMIT 8 Bytes | TERM 8 Bytes | VOTE <Var> Bytes |
| | | |
+----------------+--------------+------------------+
The storage mmap the file to avoid syscalls. Since these variables have frequent access, the implementation accesses the direct positions in mmap.
Platform Dependent: The implementation does not utilize mmap in Windows. Due to restrictions on managing files in Windows, the data is read and written directly from the file.
- Since:
- 0.5.4
- Author:
- Pedro Ruivo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddelete()longlongorg.jgroups.Addressvoidopen()voidsetCommitIndex(long commitIndex) voidsetCurrentTerm(long term) voidsetVotedFor(org.jgroups.Address address) booleanuseFsync()voiduseFsync(boolean value)
-
Constructor Details
-
MetadataStorage
-
-
Method Details
-
useFsync
public void useFsync(boolean value) -
useFsync
public boolean useFsync() -
open
- Throws:
IOException
-
close
- Throws:
IOException
-
delete
- Throws:
IOException
-
getCommitIndex
public long getCommitIndex() -
setCommitIndex
- Throws:
IOException
-
getCurrentTerm
public long getCurrentTerm() -
setCurrentTerm
- Throws:
IOException
-
getVotedFor
- Throws:
IOExceptionClassNotFoundException
-
setVotedFor
- Throws:
IOException
-