MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / CheckNewNodes

Method CheckNewNodes

store/store.go:274–306  ·  view source on GitHub ↗
(ctx context.Context, nodes []string)

Source from the content-addressed store, hash-verified

272}
273
274func (s *ClusterStore) CheckNewNodes(ctx context.Context, nodes []string) error {
275 newNodes := make(map[string]bool, 0)
276 for _, node := range nodes {
277 newNodes[node] = true
278 }
279
280 namespaces, err := s.ListNamespace(ctx)
281 if err != nil {
282 return err
283 }
284 existingNodes := make([]string, 0)
285 for _, ns := range namespaces {
286 clusters, err := s.ListCluster(ctx, ns)
287 if err != nil {
288 return err
289 }
290 for _, cluster := range clusters {
291 c, err := s.GetCluster(ctx, ns, cluster)
292 if err != nil {
293 return err
294 }
295 for _, existingNode := range c.GetNodes() {
296 if _, ok := newNodes[existingNode.Addr()]; ok {
297 existingNodes = append(existingNodes, existingNode.Addr())
298 }
299 }
300 }
301 }
302 if len(existingNodes) > 0 {
303 return fmt.Errorf("node: %w: %v", consts.ErrAlreadyExists, existingNodes)
304 }
305 return nil
306}
307
308func (s *ClusterStore) Notify() <-chan EventPayload {
309 return s.eventNotifyCh

Callers 1

TestClusterStoreFunction · 0.95

Calls 6

ListNamespaceMethod · 0.95
ListClusterMethod · 0.95
GetClusterMethod · 0.95
GetNodesMethod · 0.80
ErrorfMethod · 0.80
AddrMethod · 0.65

Tested by 1

TestClusterStoreFunction · 0.76