MCPcopy
hub / github.com/dgraph-io/dgraph / PastLife

Method PastLife

conn/node.go:292–326  ·  view source on GitHub ↗

PastLife returns the index of the snapshot before the restart (if any) and whether there was a previous state that should be recovered after a restart.

()

Source from the content-addressed store, hash-verified

290// PastLife returns the index of the snapshot before the restart (if any) and whether there was
291// a previous state that should be recovered after a restart.
292func (n *Node) PastLife() (uint64, bool, error) {
293 var (
294 sp raftpb.Snapshot
295 idx uint64
296 restart bool
297 rerr error
298 )
299 sp, rerr = n.Store.Snapshot()
300 if rerr != nil {
301 return 0, false, rerr
302 }
303 if !raft.IsEmptySnap(sp) {
304 glog.Infof("Found Snapshot.Metadata: %+v\n", sp.Metadata)
305 restart = true
306 idx = sp.Metadata.Index
307 }
308
309 var hd raftpb.HardState
310 hd, rerr = n.Store.HardState()
311 if rerr != nil {
312 return 0, false, rerr
313 }
314 if !raft.IsEmptyHardState(hd) {
315 glog.Infof("Found hardstate: %+v\n", hd)
316 restart = true
317 }
318
319 num := n.Store.NumEntries()
320 glog.Infof("Group %d found %d entries\n", n.RaftContext.Group, num)
321 // We'll always have at least one entry.
322 if num > 1 {
323 restart = true
324 }
325 return idx, restart, nil
326}
327
328const (
329 messageBatchSoftLimit = 10e6

Callers 2

initAndStartNodeMethod · 0.80
InitAndStartNodeMethod · 0.80

Calls 4

InfofMethod · 0.80
NumEntriesMethod · 0.80
HardStateMethod · 0.65
SnapshotMethod · 0.45

Tested by

no test coverage detected