seqeron 0.18.0
Loading...
Searching...
No Matches
Org.Limitless.Seqeron.Replayer.Client.SnapshotStore Class Referencesealed

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...

Classes

class  Reader
 One round's file, read record by record, its trailer known before the first. More...
 

Public Member Functions

 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.
 

Properties

long DurableRound [get]
 The newest round confirmed whose file is durable under its name; -1 for none. Any thread.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SnapshotStore()

Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.SnapshotStore ( string  directory)
inline

Opens this instance's snapshot directory.

Parameters
directorythis instance's own; created if missing
Exceptions
IOExceptionif it cannot be

Member Function Documentation

◆ Abandon()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Abandon ( )
inline

Drops the write in progress, if any.

◆ Append()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Append ( IDirectBuffer  record,
int  offset,
int  length 
)
inline

Appends one record to the file being written.

Parameters
recordholding it
offsetof its first byte
lengthits length, at most SnapshotFormat.MaxRecordLength

◆ AwaitWrites()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.AwaitWrites ( )
inline

Waits until the rounds confirmed so far are durable, or failed, and the files they replace deleted.

◆ Begin()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Begin ( long  round,
long  cutClusterSeqNo,
long  cutPosition,
long  cutTimestampNs 
)
inline

Starts writing a round's file, dropping any write still open, once the rounds before it are confirmed.

Parameters
roundits round
cutClusterSeqNoits SnapshotStarted's clusterSeqNo
cutPositionwhere that frame starts in the recording
cutTimestampNsthat frame's consensus timestamp

◆ Commit()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Commit ( int  recordCount,
long  length,
uint  crc32c,
int  formatVersion 
)
inline

Completes the file being written with its trailer, still under its temporary name.

Parameters
recordCountrecords appended
lengththeir bytes
crc32ctheir CRC-32C
formatVersionthe listener's

◆ Confirm()

void Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Confirm ( long  round)
inline

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.

Parameters
roundthe round last committed

◆ LatestRound()

long Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.LatestRound ( long  belowRound)
inline

The newest round below belowRound with a confirmed file, or -1.

Parameters
belowRoundlong.MaxValue for the newest of all

◆ Open()

Reader Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.Open ( long  round)
inline

Opens a round's file to read its records.

Parameters
roundits round
Returns
null if it has none, or its trailer is cut short or names another round

Property Documentation

◆ DurableRound

long Org.Limitless.Seqeron.Replayer.Client.SnapshotStore.DurableRound
get

The newest round confirmed whose file is durable under its name; -1 for none. Any thread.


The documentation for this class was generated from the following file: