RemoveNode removes the given node from the given group. It's the user's responsibility to ensure that node doesn't come back again before calling the api.
(ctx context.Context, req *pb.RemoveNodeRequest)
| 473 | // It's the user's responsibility to ensure that node doesn't come back again |
| 474 | // before calling the api. |
| 475 | func (s *Server) RemoveNode(ctx context.Context, req *pb.RemoveNodeRequest) (*pb.Status, error) { |
| 476 | if req.GroupId == 0 { |
| 477 | return nil, s.Node.ProposePeerRemoval(ctx, req.NodeId) |
| 478 | } |
| 479 | zp := &pb.ZeroProposal{} |
| 480 | zp.Member = &pb.Member{Id: req.NodeId, GroupId: req.GroupId, AmDead: true} |
| 481 | if _, ok := s.state.Groups[req.GroupId]; !ok { |
| 482 | return nil, errors.Errorf("No group with groupId %d found", req.GroupId) |
| 483 | } |
| 484 | if _, ok := s.state.Groups[req.GroupId].Members[req.NodeId]; !ok { |
| 485 | return nil, errors.Errorf("No node with nodeId %d found in group %d", req.NodeId, |
| 486 | req.GroupId) |
| 487 | } |
| 488 | if len(s.state.Groups[req.GroupId].Members) == 1 && len(s.state.Groups[req.GroupId]. |
| 489 | Tablets) > 0 { |
| 490 | return nil, errors.Errorf("Move all tablets from group %d before removing the last node", |
| 491 | req.GroupId) |
| 492 | } |
| 493 | if err := s.Node.proposeAndWait(ctx, zp); err != nil { |
| 494 | return nil, err |
| 495 | } |
| 496 | |
| 497 | return &pb.Status{}, nil |
| 498 | } |
| 499 | |
| 500 | // Connect is used by Alpha nodes to connect the very first time with group zero. |
| 501 | func (s *Server) Connect(ctx context.Context, |