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

Method removeNode

dgraph/cmd/zero/http.go:106–137  ·  view source on GitHub ↗

removeNode can be used to remove a node from the cluster. It takes in the RAFT id of the node and the group it belongs to. It can be used to remove Dgraph alpha and Zero nodes(group=0).

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

104// removeNode can be used to remove a node from the cluster. It takes in the RAFT id of the node
105// and the group it belongs to. It can be used to remove Dgraph alpha and Zero nodes(group=0).
106func (st *state) removeNode(w http.ResponseWriter, r *http.Request) {
107 x.AddCorsHeaders(w)
108 if r.Method == "OPTIONS" {
109 return
110 }
111 if r.Method != http.MethodGet {
112 w.WriteHeader(http.StatusBadRequest)
113 x.SetStatus(w, x.ErrorInvalidMethod, "Invalid method")
114 return
115 }
116
117 nodeId, ok := intFromQueryParam(w, r, "id")
118 if !ok {
119 return
120 }
121 groupId, ok := intFromQueryParam(w, r, "group")
122 if !ok {
123 return
124 }
125
126 if _, err := st.zero.RemoveNode(
127 context.Background(),
128 &pb.RemoveNodeRequest{NodeId: nodeId, GroupId: uint32(groupId)},
129 ); err != nil {
130 x.SetStatus(w, x.Error, err.Error())
131 return
132 }
133 _, err := fmt.Fprintf(w, "Removed node with group: %v, idx: %v", groupId, nodeId)
134 if err != nil {
135 glog.Warningf("Error while writing response: %+v", err)
136 }
137}
138
139// moveTablet can be used to move a tablet to a specific group. It takes in tablet and group as
140// argument.

Callers

nothing calls this directly

Calls 7

AddCorsHeadersFunction · 0.92
SetStatusFunction · 0.92
intFromQueryParamFunction · 0.85
WarningfMethod · 0.80
WriteHeaderMethod · 0.65
RemoveNodeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected