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

Method GetZeroFollowers

dgraphtest/zero_state.go:95–112  ·  view source on GitHub ↗

GetZeroFollowers returns the locators of all non-leader Zeros, as reported by the Zero at queryIdx.

(queryIdx int)

Source from the content-addressed store, hash-verified

93// GetZeroFollowers returns the locators of all non-leader Zeros, as reported
94// by the Zero at queryIdx.
95func (c *LocalCluster) GetZeroFollowers(queryIdx int) ([]ZeroLocator, error) {
96 state, err := c.GetZeroState(queryIdx)
97 if err != nil {
98 return nil, err
99 }
100 var followers []ZeroLocator
101 for id, z := range state.Zeros {
102 if z.Leader {
103 continue
104 }
105 idx, ok := containerIdxFromAddr(z.Addr)
106 if !ok {
107 return nil, fmt.Errorf("cannot map follower addr %q to container index", z.Addr)
108 }
109 followers = append(followers, ZeroLocator{ContainerIdx: idx, RaftID: id, Addr: z.Addr})
110 }
111 return followers, nil
112}
113
114func (c *LocalCluster) findZero(queryIdx int, wantLeader bool) (*ZeroLocator, error) {
115 state, err := c.GetZeroState(queryIdx)

Callers 1

Calls 3

GetZeroStateMethod · 0.95
containerIdxFromAddrFunction · 0.85
ErrorfMethod · 0.45

Tested by 1