Updated Raft snapshot to also persist last saved unix timestamp in milliseconds. This timestamp is re-loaded when the server is re-started.

Created standalone snapshot flow including manifest file that is used to determine whether another snapshot should be taken based on the hashed contents of the snapshot.
This commit is contained in:
Kelvin Clement Mwinuka
2024-01-28 03:36:09 +08:00
parent 06822f122f
commit d31acfbbdd
8 changed files with 313 additions and 51 deletions

View File

@@ -8,7 +8,6 @@ import (
"log"
"net"
"os"
"path"
"path/filepath"
"time"
@@ -63,7 +62,7 @@ func (r *Raft) RaftInit(ctx context.Context) {
stableStore = raft.StableStore(boltdb)
snapshotStore, err = raft.NewFileSnapshotStore(path.Join(conf.DataDir, "snapshots"), 2, os.Stdout)
snapshotStore, err = raft.NewFileSnapshotStore(conf.DataDir, 2, os.Stdout)
if err != nil {
log.Fatal(err)
}
@@ -144,10 +143,10 @@ func (r *Raft) HasJoinedCluster() bool {
}
func (r *Raft) AddVoter(
id raft.ServerID,
address raft.ServerAddress,
prevIndex uint64,
timeout time.Duration,
id raft.ServerID,
address raft.ServerAddress,
prevIndex uint64,
timeout time.Duration,
) error {
if r.IsRaftLeader() {
raftConfig := r.raft.GetConfiguration()