This instance's own snapshots, in a directory no other instance writes (doc/snapshot.md §4.1). A round is written as <round>.tmp: the records, each a little-endian uint16 length and its bytes, record 0 the façade's header, then a trailer:
More...
|
| | SnapshotStore (string directory) |
| | Opens this instance's snapshot directory.
|
| |
| void | Begin (long round, long cutClusterSeqNo, long cutPosition, long cutTimestampNs) |
| | Starts writing a round's file, dropping any write still open, once the rounds before it are confirmed.
|
| |
| void | Append (IDirectBuffer record, int offset, int length) |
| | Appends one record to the file being written.
|
| |
| void | Commit (int recordCount, long length, uint crc32c, int formatVersion) |
| | Completes the file being written with its trailer, still under its temporary name.
|
| |
| void | Abandon () |
| | Drops the write in progress, if any.
|
| |
| void | Confirm (long round) |
| | The log confirms round : off this thread, its file is made durable under its name, and every older file but the newest confirmed one, and any write of one a crash left behind, is deleted. Nothing if its file was not completed. DurableRound names it once it is durable.
|
| |
| void | AwaitWrites () |
| | Waits until the rounds confirmed so far are durable, or failed, and the files they replace deleted.
|
| |
| long | LatestRound (long belowRound) |
| | The newest round below belowRound with a confirmed file, or -1.
|
| |
| Reader | Open (long round) |
| | Opens a round's file to read its records.
|
| |
This instance's own snapshots, in a directory no other instance writes (doc/snapshot.md §4.1). A round is written as <round>.tmp: the records, each a little-endian uint16 length and its bytes, record 0 the façade's header, then a trailer:
0 round int64 8 length int64 the records' bytes, as SnapshotEnd.length 16 recordCount int32 20 crc32c uint32 24 formatVersion uint32 28 cutClusterSeqNo int64 the round's SnapshotStarted 36 cutPosition int64 where that frame starts in the recording 44 cutTimestamp int64 its consensus timestamp 52 magic uint32 Magic Once the log confirms the round, a thread of its own forces the file to disk, renames it <round>.snapshot and deletes every older file but the newest confirmed one, so the caller does not wait for the disk: a .snapshot file is confirmed and durable, and the store keeps two, the older to restore from when the newer is damaged. .NET forces no directory; a journaling file system commits the rename before the deletions that follow it. A write that fails leaves no file and is logged. Not thread-safe: one thread calls it, and only its file work runs on the other. SnapshotStore.java and SnapshotStore.hpp are its twins; keep the three in step.