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

Method ProposeConfChange

conn/node.go:564–587  ·  view source on GitHub ↗

ProposeConfChange proposes a Raft configuration change (add, remove, or update a node) and blocks until it is committed or the context expires. It is used by both the conn package internally and by the zero package (for address reconciliation via ConfChangeUpdateNode).

(ctx context.Context, conf raftpb.ConfChange)

Source from the content-addressed store, hash-verified

562// It is used by both the conn package internally and by the zero package
563// (for address reconciliation via ConfChangeUpdateNode).
564func (n *Node) ProposeConfChange(ctx context.Context, conf raftpb.ConfChange) error {
565 cctx, cancel := context.WithTimeout(ctx, 3*time.Second)
566 defer cancel()
567
568 ch := make(chan error, 1)
569 id := n.storeConfChange(ch)
570 // TODO: Delete id from the map.
571 conf.ID = id
572 if err := n.Raft().ProposeConfChange(cctx, conf); err != nil {
573 if cctx.Err() != nil {
574 return errInternalRetry
575 }
576 glog.Warningf("Error while proposing conf change: %v", err)
577 return err
578 }
579 select {
580 case err := <-ch:
581 return err
582 case <-ctx.Done():
583 return ctx.Err()
584 case <-cctx.Done():
585 return errInternalRetry
586 }
587}
588
589func (n *Node) addToCluster(ctx context.Context, rc *pb.RaftContext) error {
590 pid := rc.Id

Callers 3

addToClusterMethod · 0.95
ProposePeerRemovalMethod · 0.95

Calls 4

storeConfChangeMethod · 0.95
RaftMethod · 0.95
WarningfMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected