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

Method ChangeZeroAddress

dgraphtest/zero_state.go:193–212  ·  view source on GitHub ↗

ChangeZeroAddress reconfigures the Zero at id with a new --my flag that points to its Docker container name (a valid DNS alias on the cluster network). The Zero is stopped, recreated with its WAL preserved, and restarted. The new address is returned so callers can assert convergence.

(id int)

Source from the content-addressed store, hash-verified

191// network). The Zero is stopped, recreated with its WAL preserved, and
192// restarted. The new address is returned so callers can assert convergence.
193func (c *LocalCluster) ChangeZeroAddress(id int) (string, error) {
194 if err := c.StopZero(id); err != nil {
195 return "", err
196 }
197 containerName, err := c.GetZeroContainerName(id)
198 if err != nil {
199 return "", err
200 }
201 newAddr := containerName + ":" + zeroGrpcPort
202 if err := c.SetZeroMyAddr(id, newAddr); err != nil {
203 return "", err
204 }
205 if err := c.RecreateZero(id); err != nil {
206 return "", err
207 }
208 if err := c.StartZero(id); err != nil {
209 return "", err
210 }
211 return newAddr, nil
212}
213
214// containerIdxFromAddr extracts the numeric suffix from the "zeroN" segment
215// of a member's address and returns it as the container index used by tests.

Calls 5

StopZeroMethod · 0.95
GetZeroContainerNameMethod · 0.95
SetZeroMyAddrMethod · 0.95
RecreateZeroMethod · 0.95
StartZeroMethod · 0.95