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

Method applyEntries

store/engine/raft/node.go:453–469  ·  view source on GitHub ↗
(entries []raftpb.Entry)

Source from the content-addressed store, hash-verified

451}
452
453func (n *Node) applyEntries(entries []raftpb.Entry) {
454 if len(entries) == 0 || entries[0].Index > n.appliedIndex+1 {
455 return
456 }
457
458 firstEntryIndex := entries[0].Index
459 // remove entries that have been applied
460 if n.appliedIndex-firstEntryIndex+1 < uint64(len(entries)) {
461 entries = entries[n.appliedIndex-firstEntryIndex+1:]
462 }
463 for _, entry := range entries {
464 if err := n.applyEntry(entry); err != nil {
465 n.logger.Error("failed to apply entry", zap.Error(err))
466 }
467 }
468 n.appliedIndex = entries[len(entries)-1].Index
469}
470
471func (n *Node) applyEntry(entry raftpb.Entry) error {
472 switch entry.Type {

Callers 1

runRaftMessagesMethod · 0.95

Implementers 1

ClusterNodestore/cluster_node.go

Calls 2

applyEntryMethod · 0.95
ErrorMethod · 0.80

Tested by

no test coverage detected