MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / applySnapshot

Method applySnapshot

store/engine/raft/node.go:433–451  ·  view source on GitHub ↗
(snapshot raftpb.Snapshot)

Source from the content-addressed store, hash-verified

431}
432
433func (n *Node) applySnapshot(snapshot raftpb.Snapshot) error {
434 if raft.IsEmptySnap(snapshot) {
435 return nil
436 }
437
438 _ = n.dataStore.raftStorage.ApplySnapshot(snapshot)
439 if n.appliedIndex >= snapshot.Metadata.Index {
440 return fmt.Errorf("snapshot index [%d] should be greater than applied index [%d]", snapshot.Metadata.Index, n.appliedIndex)
441 }
442
443 // Load the snapshot into the key-value store.
444 if err := n.dataStore.reloadSnapshot(); err != nil {
445 return err
446 }
447 n.confState = snapshot.Metadata.ConfState
448 n.appliedIndex = snapshot.Metadata.Index
449 n.snapshotIndex = snapshot.Metadata.Index
450 return nil
451}
452
453func (n *Node) applyEntries(entries []raftpb.Entry) {
454 if len(entries) == 0 || entries[0].Index > n.appliedIndex+1 {

Callers 1

runRaftMessagesMethod · 0.95

Implementers 1

ClusterNodestore/cluster_node.go

Calls 2

ErrorfMethod · 0.80
reloadSnapshotMethod · 0.80

Tested by

no test coverage detected