(ctx context.Context, rc *pb.RaftContext)
| 587 | } |
| 588 | |
| 589 | func (n *Node) addToCluster(ctx context.Context, rc *pb.RaftContext) error { |
| 590 | pid := rc.Id |
| 591 | rc.SnapshotTs = 0 |
| 592 | rcBytes, err := proto.Marshal(rc) |
| 593 | x.Check(err) |
| 594 | |
| 595 | cc := raftpb.ConfChange{ |
| 596 | Type: raftpb.ConfChangeAddNode, |
| 597 | NodeID: pid, |
| 598 | Context: rcBytes, |
| 599 | } |
| 600 | if rc.IsLearner { |
| 601 | cc.Type = raftpb.ConfChangeAddLearnerNode |
| 602 | } |
| 603 | |
| 604 | err = errInternalRetry |
| 605 | for err == errInternalRetry { |
| 606 | glog.Infof("Trying to add %#x to cluster. Addr: %v\n", pid, rc.Addr) |
| 607 | glog.Infof("Current confstate at %#x: %+v\n", n.Id, n.ConfState()) |
| 608 | err = n.ProposeConfChange(ctx, cc) |
| 609 | } |
| 610 | return err |
| 611 | } |
| 612 | |
| 613 | // ProposePeerRemoval proposes a new configuration with the peer with the given id removed. |
| 614 | func (n *Node) ProposePeerRemoval(ctx context.Context, id uint64) error { |
no test coverage detected