(snapshot raftpb.Snapshot)
| 431 | } |
| 432 | |
| 433 | func (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 | |
| 453 | func (n *Node) applyEntries(entries []raftpb.Entry) { |
| 454 | if len(entries) == 0 || entries[0].Index > n.appliedIndex+1 { |
no test coverage detected