MCPcopy
hub / github.com/chaozh/MIT-6.824 / nCommitted

Method nCommitted

src/raft/config.go:433–455  ·  view source on GitHub ↗

how many servers think a log entry is committed?

(index int)

Source from the content-addressed store, hash-verified

431
432// how many servers think a log entry is committed?
433func (cfg *config) nCommitted(index int) (int, interface{}) {
434 count := 0
435 var cmd interface{} = nil
436 for i := 0; i < len(cfg.rafts); i++ {
437 if cfg.applyErr[i] != "" {
438 cfg.t.Fatal(cfg.applyErr[i])
439 }
440
441 cfg.mu.Lock()
442 cmd1, ok := cfg.logs[i][index]
443 cfg.mu.Unlock()
444
445 if ok {
446 if count > 0 && cmd != cmd1 {
447 cfg.t.Fatalf("committed values do not match: index %v, %v, %v\n",
448 index, cmd, cmd1)
449 }
450 count += 1
451 cmd = cmd1
452 }
453 }
454 return count, cmd
455}
456
457// wait for at least n servers to commit.
458// but don't wait forever.

Callers 5

waitMethod · 0.95
oneMethod · 0.95
TestBasicAgree2BFunction · 0.80
TestFailNoAgree2BFunction · 0.80
internalChurnFunction · 0.80

Calls

no outgoing calls

Tested by 3

TestBasicAgree2BFunction · 0.64
TestFailNoAgree2BFunction · 0.64
internalChurnFunction · 0.64