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

Method crash1

src/raft/config.go:105–134  ·  view source on GitHub ↗

shut down a Raft server but save its persistent state.

(i int)

Source from the content-addressed store, hash-verified

103
104// shut down a Raft server but save its persistent state.
105func (cfg *config) crash1(i int) {
106 cfg.disconnect(i)
107 cfg.net.DeleteServer(i) // disable client connections to the server.
108
109 cfg.mu.Lock()
110 defer cfg.mu.Unlock()
111
112 // a fresh persister, in case old instance
113 // continues to update the Persister.
114 // but copy old persister's content so that we always
115 // pass Make() the last persisted state.
116 if cfg.saved[i] != nil {
117 cfg.saved[i] = cfg.saved[i].Copy()
118 }
119
120 rf := cfg.rafts[i]
121 if rf != nil {
122 cfg.mu.Unlock()
123 rf.Kill()
124 cfg.mu.Lock()
125 cfg.rafts[i] = nil
126 }
127
128 if cfg.saved[i] != nil {
129 raftlog := cfg.saved[i].ReadRaftState()
130 snapshot := cfg.saved[i].ReadSnapshot()
131 cfg.saved[i] = &Persister{}
132 cfg.saved[i].SaveStateAndSnapshot(raftlog, snapshot)
133 }
134}
135
136func (cfg *config) checkLogs(i int, m ApplyMsg) (string, bool) {
137 err_msg := ""

Callers 5

start1Method · 0.95
TestPersist32CFunction · 0.80
TestFigure82CFunction · 0.80
internalChurnFunction · 0.80
snapcommonFunction · 0.80

Calls 7

disconnectMethod · 0.95
DeleteServerMethod · 0.80
CopyMethod · 0.80
ReadRaftStateMethod · 0.80
ReadSnapshotMethod · 0.80
SaveStateAndSnapshotMethod · 0.80
KillMethod · 0.45

Tested by 4

TestPersist32CFunction · 0.64
TestFigure82CFunction · 0.64
internalChurnFunction · 0.64
snapcommonFunction · 0.64