public class NodeStateFile extends Object implements AutoCloseable
The structure consists of a node header at the beginning of the file followed by n entries that use the standard open framing header, followed by the message header, and finally the body.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Node State Header | +---------------------------------------------------------------+
Entry. All records must be laid out so that the body has an 8-byte alignment. Fields that require volatile accesses must be aligned to an 8-byte boundary. The message header is 8-bytes long to aid with this. Records are padded to a 8-byte boundary before the next record.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +---------------------------------------------------------------+ | Message Header | | | +---------------------------------------------------------------+ | Message Body (Variable) ... ... | +---------------------------------------------------------------+
The current structure contains:
<Node State Header>
<Candidate Term>
<Cluster Members>
<Node State Footer>
| Modifier and Type | Class and Description |
|---|---|
class |
NodeStateFile.CandidateTerm
Wrapper class for the candidate term.
|
| Constructor and Description |
|---|
NodeStateFile(File clusterDir,
boolean createNew,
int fileSyncLevel)
Construct the NodeStateFile.
|
| Modifier and Type | Method and Description |
|---|---|
NodeStateFile.CandidateTerm |
candidateTerm()
Get the reference to CandidateTerm wrapper that can be used to fetch the values associated with the current
candidate term.
|
void |
close() |
long |
proposeMaxCandidateTermId(long candidateTermId,
long logPosition,
long timestampMs)
Set the current candidate term id with associated information.
|
void |
updateCandidateTermId(long candidateTermId,
long logPosition,
long timestampMs)
Set the current candidate term id with associated information.
|
public static final String FILENAME
public NodeStateFile(File clusterDir, boolean createNew, int fileSyncLevel) throws IOException
clusterDir - directory containing the NodeStateFile.createNew - whether a new file should be created if one does not already exist.fileSyncLevel - whether the mapped byte buffer should be synchronised with the underlying filesystem on
change.IOException - if there is an error creating the file or createNew == false and the file does
not already exist.public void close()
close in interface AutoCloseablepublic void updateCandidateTermId(long candidateTermId,
long logPosition,
long timestampMs)
candidateTermId - current candidate term id.logPosition - log position where the term id change occurred.timestampMs - timestamp of the candidate term id change.public long proposeMaxCandidateTermId(long candidateTermId,
long logPosition,
long timestampMs)
candidateTermId - current candidate term id.logPosition - log position where the term id change occurred.timestampMs - timestamp of the candidate term id change.public NodeStateFile.CandidateTerm candidateTerm()
Copyright © 2014-2023 Real Logic Limited. All Rights Reserved.