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

Method RemoveNode

dgraph/cmd/zero/zero.go:475–498  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

473// It's the user's responsibility to ensure that node doesn't come back again
474// before calling the api.
475func (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.
501func (s *Server) Connect(ctx context.Context,

Callers 1

TestRemoveNodeFunction · 0.95

Calls 3

ProposePeerRemovalMethod · 0.80
ErrorfMethod · 0.45
proposeAndWaitMethod · 0.45

Tested by 1

TestRemoveNodeFunction · 0.76