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

Function newNode

worker/draft.go:256–282  ·  view source on GitHub ↗

Now that we apply txn updates via Raft, waiting based on Txn timestamps is sufficient. We don't need to wait for proposals to be applied.

(store *raftwal.DiskStorage, gid uint32, id uint64, myAddr string)

Source from the content-addressed store, hash-verified

254// sufficient. We don't need to wait for proposals to be applied.
255
256func newNode(store *raftwal.DiskStorage, gid uint32, id uint64, myAddr string) *node {
257 glog.Infof("Node ID: %#x with GroupID: %d\n", id, gid)
258
259 isLearner := x.WorkerConfig.Raft.GetBool("learner")
260 rc := &pb.RaftContext{
261 Addr: myAddr,
262 Group: gid,
263 Id: id,
264 IsLearner: isLearner,
265 }
266 glog.Infof("RaftContext: %+v\n", rc)
267 m := conn.NewNode(rc, store, x.WorkerConfig.TLSClientConfig)
268
269 n := &node{
270 Node: m,
271 ctx: context.Background(),
272 gid: gid,
273 // We need a generous size for applyCh, because raft.Tick happens every
274 // 10ms. If we restrict the size here, then Raft goes into a loop trying
275 // to maintain quorum health.
276 applyCh: make(chan []raftpb.Entry, 1000),
277 closer: z.NewCloser(4), // Matches CLOSER:1
278 ops: make(map[op]operation),
279 cdcTracker: newCDC(),
280 }
281 return n
282}
283
284func (n *node) Ctx(key uint64) context.Context {
285 if pctx := n.Proposals.Get(key); pctx != nil {

Callers 2

TestCalculateSnapshotFunction · 0.85
StartRaftNodesFunction · 0.85

Calls 3

NewNodeFunction · 0.92
newCDCFunction · 0.85
InfofMethod · 0.80

Tested by 1

TestCalculateSnapshotFunction · 0.68